1. Introduction
  2. Getting Started
  3. 1. Installation
  4. 2. First Steps with Foundry
  5. Projects
  6. 3. Creating a New Project
  7. 4. Working on an Existing Project
  8. 5. Dependencies
  9. 6. Project Layout
  10. Forge Overview
  11. 7. Overview of Forge
  12. 8. Tests
    ❱
    1. 8.1. Writing Tests
    2. 8.2. Cheatcodes
    3. 8.3. Forge Standard Library Overview
    4. 8.4. Understanding Traces
    5. 8.5. Fork Testing
  13. 9. Advanced Testing
    ❱
    1. 9.1. Fuzz Testing
    2. 9.2. Invariant Testing
    3. 9.3. Differential Testing
  14. 10. Deploying and Verifying
  15. 11. Gas Tracking
    ❱
    1. 11.1. Gas Reports
    2. 11.2. Gas Snapshots
  16. 12. Debugger
  17. Cast Overview
  18. 13. Overview of Cast
  19. Anvil Overview
  20. 14. Overview of Anvil
  21. Chisel Overview
  22. 15. Overview of Chisel
  23. Configuration
  24. 16. Configuring with foundry.toml
  25. 17. Continuous Integration
  26. 18. Integrating with VSCode
  27. 19. Shell Autocompletion
  28. 20. Static Analyzers
  29. 21. Integrating with Hardhat
  30. Tutorials
  31. 22. Best Practices
  32. 23. Creating an NFT with Solmate
  33. 24. Docker and Foundry
  34. 25. Testing EIP-712 Signatures
  35. 26. Solidity Scripting
  36. 27. Deterministic deployment using CREATE2
  37. 28. Forking Mainnet with Cast and Anvil
  38. 29. Learning Foundry Videos
  39. Appendix
  40. 30. FAQ
  41. 31. Help us improve Foundry
  42. 32. References
    ❱
    1. 32.1. CLI Reference
      ❱
      1. 32.1.1. forge
        ❱
        1. 32.1.1.1. forge bind
        2. 32.1.1.2. forge build
        3. 32.1.1.3. forge cache
          ❱
          1. 32.1.1.3.1. forge cache clean
          2. 32.1.1.3.2. forge cache ls
        4. 32.1.1.4. forge clean
        5. 32.1.1.5. forge completions
        6. 32.1.1.6. forge config
        7. 32.1.1.7. forge coverage
        8. 32.1.1.8. forge create
        9. 32.1.1.9. forge debug
        10. 32.1.1.10. forge doc
        11. 32.1.1.11. forge flatten
        12. 32.1.1.12. forge fmt
        13. 32.1.1.13. forge geiger
        14. 32.1.1.14. forge generate
          ❱
          1. 32.1.1.14.1. forge generate test
        15. 32.1.1.15. forge generate-fig-spec
        16. 32.1.1.16. forge init
        17. 32.1.1.17. forge inspect
        18. 32.1.1.18. forge install
        19. 32.1.1.19. forge remappings
        20. 32.1.1.20. forge remove
        21. 32.1.1.21. forge script
        22. 32.1.1.22. forge selectors
          ❱
          1. 32.1.1.22.1. forge selectors collision
          2. 32.1.1.22.2. forge selectors upload
          3. 32.1.1.22.3. forge selectors list
        23. 32.1.1.23. forge snapshot
        24. 32.1.1.24. forge test
        25. 32.1.1.25. forge tree
        26. 32.1.1.26. forge update
        27. 32.1.1.27. forge verify-check
        28. 32.1.1.28. forge verify-contract
      2. 32.1.2. cast
        ❱
        1. 32.1.2.1. cast 4byte
        2. 32.1.2.2. cast 4byte-decode
        3. 32.1.2.3. cast 4byte-event
        4. 32.1.2.4. cast abi-decode
        5. 32.1.2.5. cast abi-encode
        6. 32.1.2.6. cast access-list
        7. 32.1.2.7. cast address-zero
        8. 32.1.2.8. cast admin
        9. 32.1.2.9. cast age
        10. 32.1.2.10. cast balance
        11. 32.1.2.11. cast base-fee
        12. 32.1.2.12. cast bind
        13. 32.1.2.13. cast block
        14. 32.1.2.14. cast block-number
        15. 32.1.2.15. cast call
          ❱
          1. 32.1.2.15.1. cast call --create
        16. 32.1.2.16. cast calldata
        17. 32.1.2.17. cast calldata-decode
        18. 32.1.2.18. cast chain
        19. 32.1.2.19. cast chain-id
        20. 32.1.2.20. cast client
        21. 32.1.2.21. cast code
        22. 32.1.2.22. cast codesize
        23. 32.1.2.23. cast completions
        24. 32.1.2.24. cast compute-address
        25. 32.1.2.25. cast concat-hex
        26. 32.1.2.26. cast create2
        27. 32.1.2.27. cast decode-transaction
        28. 32.1.2.28. cast disassemble
        29. 32.1.2.29. cast estimate
          ❱
          1. 32.1.2.29.1. cast estimate --create
        30. 32.1.2.30. cast etherscan-source
        31. 32.1.2.31. cast find-block
        32. 32.1.2.32. cast format-bytes32-string
        33. 32.1.2.33. cast from-bin
        34. 32.1.2.34. cast from-fixed-point
        35. 32.1.2.35. cast from-rlp
        36. 32.1.2.36. cast from-utf8
        37. 32.1.2.37. cast from-wei
        38. 32.1.2.38. cast gas-price
        39. 32.1.2.39. cast generate-fig-spec
        40. 32.1.2.40. cast hash-zero
        41. 32.1.2.41. cast implementation
        42. 32.1.2.42. cast index
        43. 32.1.2.43. cast interface
        44. 32.1.2.44. cast keccak
        45. 32.1.2.45. cast logs
        46. 32.1.2.46. cast lookup-address
        47. 32.1.2.47. cast max-int
        48. 32.1.2.48. cast max-uint
        49. 32.1.2.49. cast min-int
        50. 32.1.2.50. cast namehash
        51. 32.1.2.51. cast nonce
        52. 32.1.2.52. cast parse-bytes32-address
        53. 32.1.2.53. cast parse-bytes32-string
        54. 32.1.2.54. cast pretty-calldata
        55. 32.1.2.55. cast proof
        56. 32.1.2.56. cast publish
        57. 32.1.2.57. cast receipt
        58. 32.1.2.58. cast resolve-name
        59. 32.1.2.59. cast rpc
        60. 32.1.2.60. cast run
        61. 32.1.2.61. cast selectors
        62. 32.1.2.62. cast send
          ❱
          1. 32.1.2.62.1. cast send --create
        63. 32.1.2.63. cast shl
        64. 32.1.2.64. cast shr
        65. 32.1.2.65. cast sig
        66. 32.1.2.66. cast sig-event
        67. 32.1.2.67. cast storage
        68. 32.1.2.68. cast to-ascii
        69. 32.1.2.69. cast to-base
        70. 32.1.2.70. cast to-bytes32
        71. 32.1.2.71. cast to-check-sum-address
        72. 32.1.2.72. cast to-dec
        73. 32.1.2.73. cast to-fixed-point
        74. 32.1.2.74. cast to-hex
        75. 32.1.2.75. cast to-hexdata
        76. 32.1.2.76. cast to-int256
        77. 32.1.2.77. cast to-rlp
        78. 32.1.2.78. cast to-uint256
        79. 32.1.2.79. cast to-unit
        80. 32.1.2.80. cast to-wei
        81. 32.1.2.81. cast tx
        82. 32.1.2.82. cast upload-signature
        83. 32.1.2.83. cast wallet
          ❱
          1. 32.1.2.83.1. cast wallet new
          2. 32.1.2.83.2. cast wallet new-mnemonic
          3. 32.1.2.83.3. cast wallet vanity
          4. 32.1.2.83.4. cast wallet address
          5. 32.1.2.83.5. cast wallet sign
          6. 32.1.2.83.6. cast wallet verify
          7. 32.1.2.83.7. cast wallet import
          8. 32.1.2.83.8. cast wallet list
          9. 32.1.2.83.9. cast wallet derive-private-key
      3. 32.1.3. anvil
        ❱
        1. 32.1.3.1. anvil completions
        2. 32.1.3.2. anvil generate-fig-spec
      4. 32.1.4. chisel
        ❱
        1. 32.1.4.1. chisel list
        2. 32.1.4.2. chisel load
        3. 32.1.4.3. chisel view
        4. 32.1.4.4. chisel clear-cache
    2. 32.2. forge Commands
      ❱
      1. 32.2.1. General Commands
        ❱
        1. 32.2.1.1. forge
        2. 32.2.1.2. forge help
        3. 32.2.1.3. forge completions
      2. 32.2.2. Project Commands
        ❱
        1. 32.2.2.1. forge init
        2. 32.2.2.2. forge install
        3. 32.2.2.3. forge update
        4. 32.2.2.4. forge remove
        5. 32.2.2.5. forge config
        6. 32.2.2.6. forge remappings
        7. 32.2.2.7. forge tree
        8. 32.2.2.8. forge geiger
      3. 32.2.3. Build Commands
        ❱
        1. 32.2.3.1. forge build
        2. 32.2.3.2. forge clean
        3. 32.2.3.3. forge inspect
      4. 32.2.4. Test Commands
        ❱
        1. 32.2.4.1. forge test
        2. 32.2.4.2. forge snapshot
        3. 32.2.4.3. forge coverage
      5. 32.2.5. Deploy Commands
        ❱
        1. 32.2.5.1. forge create
        2. 32.2.5.2. forge verify-contract
        3. 32.2.5.3. forge verify-check
        4. 32.2.5.4. forge flatten
      6. 32.2.6. Utility Commands
        ❱
        1. 32.2.6.1. forge debug
        2. 32.2.6.2. forge bind
        3. 32.2.6.3. forge cache
        4. 32.2.6.4. forge cache clean
        5. 32.2.6.5. forge cache ls
        6. 32.2.6.6. forge script
        7. 32.2.6.7. forge upload-selectors
        8. 32.2.6.8. forge doc
    3. 32.3. cast Commands
      ❱
      1. 32.3.1. General Commands
        ❱
        1. 32.3.1.1. cast
        2. 32.3.1.2. cast help
        3. 32.3.1.3. cast completions
      2. 32.3.2. Chain Commands
        ❱
        1. 32.3.2.1. cast chain-id
        2. 32.3.2.2. cast chain
        3. 32.3.2.3. cast client
      3. 32.3.3. Transaction Commands
        ❱
        1. 32.3.3.1. cast publish
        2. 32.3.3.2. cast receipt
        3. 32.3.3.3. cast send
        4. 32.3.3.4. cast call
        5. 32.3.3.5. cast rpc
        6. 32.3.3.6. cast tx
        7. 32.3.3.7. cast run
        8. 32.3.3.8. cast estimate
        9. 32.3.3.9. cast access-list
        10. 32.3.3.10. cast logs
      4. 32.3.4. Block Commands
        ❱
        1. 32.3.4.1. cast find-block
        2. 32.3.4.2. cast gas-price
        3. 32.3.4.3. cast block-number
        4. 32.3.4.4. cast basefee
        5. 32.3.4.5. cast block
        6. 32.3.4.6. cast age
      5. 32.3.5. Account Commands
        ❱
        1. 32.3.5.1. cast balance
        2. 32.3.5.2. cast storage
        3. 32.3.5.3. cast proof
        4. 32.3.5.4. cast nonce
        5. 32.3.5.5. cast code
        6. 32.3.5.6. cast codesize
      6. 32.3.6. ENS Commands
        ❱
        1. 32.3.6.1. cast lookup-address
        2. 32.3.6.2. cast resolve-name
        3. 32.3.6.3. cast namehash
      7. 32.3.7. Etherscan Commands
        ❱
        1. 32.3.7.1. cast etherscan-source
      8. 32.3.8. ABI Commands
        ❱
        1. 32.3.8.1. cast abi-decode
        2. 32.3.8.2. cast abi-encode
        3. 32.3.8.3. cast 4byte
        4. 32.3.8.4. cast 4byte-decode
        5. 32.3.8.5. cast 4byte-event
        6. 32.3.8.6. cast calldata
        7. 32.3.8.7. cast calldata-decode
        8. 32.3.8.8. cast pretty-calldata
        9. 32.3.8.9. cast selectors
        10. 32.3.8.10. cast upload-signature
      9. 32.3.9. Conversion Commands
        ❱
        1. 32.3.9.1. cast format-bytes32-string
        2. 32.3.9.2. cast from-bin
        3. 32.3.9.3. cast from-fixed-point
        4. 32.3.9.4. cast from-rlp
        5. 32.3.9.5. cast from-utf8
        6. 32.3.9.6. cast from-wei
        7. 32.3.9.7. cast parse-bytes32-address
        8. 32.3.9.8. cast parse-bytes32-string
        9. 32.3.9.9. cast to-ascii
        10. 32.3.9.10. cast to-base
        11. 32.3.9.11. cast to-bytes32
        12. 32.3.9.12. cast to-dec
        13. 32.3.9.13. cast to-fixed-point
        14. 32.3.9.14. cast to-hex
        15. 32.3.9.15. cast to-hexdata
        16. 32.3.9.16. cast to-int256
        17. 32.3.9.17. cast to-rlp
        18. 32.3.9.18. cast to-uint256
        19. 32.3.9.19. cast to-unit
        20. 32.3.9.20. cast to-wei
        21. 32.3.9.21. cast shl
        22. 32.3.9.22. cast shr
      10. 32.3.10. Utility Commands
        ❱
        1. 32.3.10.1. cast sig
        2. 32.3.10.2. cast sig-event
        3. 32.3.10.3. cast keccak
        4. 32.3.10.4. cast compute-address
        5. 32.3.10.5. cast create2
        6. 32.3.10.6. cast interface
        7. 32.3.10.7. cast index
        8. 32.3.10.8. cast concat-hex
        9. 32.3.10.9. cast max-int
        10. 32.3.10.10. cast min-int
        11. 32.3.10.11. cast max-uint
        12. 32.3.10.12. cast to-check-sum-address
      11. 32.3.11. Wallet Commands
        ❱
        1. 32.3.11.1. cast wallet
        2. 32.3.11.2. cast wallet new
        3. 32.3.11.3. cast wallet new-mnemonic
        4. 32.3.11.4. cast wallet address
        5. 32.3.11.5. cast wallet sign
        6. 32.3.11.6. cast wallet vanity
        7. 32.3.11.7. cast wallet verify
        8. 32.3.11.8. cast wallet import
        9. 32.3.11.9. cast wallet list
    4. 32.4. anvil Reference
    5. 32.5. chisel Reference
    6. 32.6. Config Reference
      ❱
      1. 32.6.1. Overview
      2. 32.6.2. Project
      3. 32.6.3. Solidity Compiler
      4. 32.6.4. Testing
      5. 32.6.5. In-line Configuration Testing
      6. 32.6.6. Formatter
      7. 32.6.7. Documentation Generator
      8. 32.6.8. Etherscan
    7. 32.7. Cheatcodes Reference
      ❱
      1. 32.7.1. Environment
        ❱
        1. 32.7.1.1. warp
        2. 32.7.1.2. roll
        3. 32.7.1.3. fee
        4. 32.7.1.4. getBlockTimestamp
        5. 32.7.1.5. getBlockNumber
        6. 32.7.1.6. difficulty
        7. 32.7.1.7. prevrandao
        8. 32.7.1.8. chainId
        9. 32.7.1.9. store
        10. 32.7.1.10. load
        11. 32.7.1.11. etch
        12. 32.7.1.12. deal
        13. 32.7.1.13. prank
        14. 32.7.1.14. startPrank
        15. 32.7.1.15. stopPrank
        16. 32.7.1.16. readCallers
        17. 32.7.1.17. record
        18. 32.7.1.18. accesses
        19. 32.7.1.19. recordLogs
        20. 32.7.1.20. getRecordedLogs
        21. 32.7.1.21. setNonce
        22. 32.7.1.22. getNonce
        23. 32.7.1.23. mockCall
        24. 32.7.1.24. mockCallRevert
        25. 32.7.1.25. clearMockedCalls
        26. 32.7.1.26. coinbase
        27. 32.7.1.27. broadcast
        28. 32.7.1.28. startBroadcast
        29. 32.7.1.29. stopBroadcast
        30. 32.7.1.30. pauseGasMetering
        31. 32.7.1.31. resumeGasMetering
        32. 32.7.1.32. txGasPrice
        33. 32.7.1.33. startStateDiffRecording
        34. 32.7.1.34. stopAndReturnStateDiff
      2. 32.7.2. Assertions
        ❱
        1. 32.7.2.1. expectRevert
        2. 32.7.2.2. expectEmit
        3. 32.7.2.3. expectCall
      3. 32.7.3. Fuzzer
        ❱
        1. 32.7.3.1. assume
      4. 32.7.4. Forking
        ❱
        1. 32.7.4.1. createFork
        2. 32.7.4.2. selectFork
        3. 32.7.4.3. createSelectFork
        4. 32.7.4.4. activeFork
        5. 32.7.4.5. rollFork
        6. 32.7.4.6. makePersistent
        7. 32.7.4.7. revokePersistent
        8. 32.7.4.8. isPersistent
        9. 32.7.4.9. allowCheatcodes
        10. 32.7.4.10. transact
      5. 32.7.5. External
        ❱
        1. 32.7.5.1. ffi
        2. 32.7.5.2. projectRoot
        3. 32.7.5.3. getCode
        4. 32.7.5.4. getDeployedCode
        5. 32.7.5.5. sleep
        6. 32.7.5.6. unixTime
        7. 32.7.5.7. setEnv
        8. 32.7.5.8. envOr
        9. 32.7.5.9. envBool
        10. 32.7.5.10. envUint
        11. 32.7.5.11. envInt
        12. 32.7.5.12. envAddress
        13. 32.7.5.13. envBytes32
        14. 32.7.5.14. envString
        15. 32.7.5.15. envBytes
        16. 32.7.5.16. parseJson
        17. 32.7.5.17. keyExists
        18. 32.7.5.18. parseJsonKeys
        19. 32.7.5.19. serializeJson
        20. 32.7.5.20. writeJson
      6. 32.7.6. Utilities
        ❱
        1. 32.7.6.1. addr
        2. 32.7.6.2. sign
        3. 32.7.6.3. skip
        4. 32.7.6.4. label
        5. 32.7.6.5. getLabel
        6. 32.7.6.6. deriveKey
        7. 32.7.6.7. parseBytes
        8. 32.7.6.8. parseAddress
        9. 32.7.6.9. parseUint
        10. 32.7.6.10. parseInt
        11. 32.7.6.11. parseBytes32
        12. 32.7.6.12. parseBool
        13. 32.7.6.13. rememberKey
        14. 32.7.6.14. toString
        15. 32.7.6.15. breakpoint
        16. 32.7.6.16. createWallet
      7. 32.7.7. Snapshots
      8. 32.7.8. RPC
      9. 32.7.9. Files
    8. 32.8. Forge Standard Library Reference
      ❱
      1. 32.8.1. Std Logs
      2. 32.8.2. Std Assertions
        ❱
        1. 32.8.2.1. fail
        2. 32.8.2.2. assertFalse
        3. 32.8.2.3. assertEq
        4. 32.8.2.4. assertApproxEqAbs
        5. 32.8.2.5. assertApproxEqRel
      3. 32.8.3. Std Cheats
        ❱
        1. 32.8.3.1. skip
        2. 32.8.3.2. rewind
        3. 32.8.3.3. hoax
        4. 32.8.3.4. startHoax
        5. 32.8.3.5. deal
        6. 32.8.3.6. deployCode
        7. 32.8.3.7. deployCodeTo
        8. 32.8.3.8. bound
        9. 32.8.3.9. changePrank
        10. 32.8.3.10. makeAddr
        11. 32.8.3.11. makeAddrAndKey
        12. 32.8.3.12. noGasMetering
        13. 32.8.3.13. assumeNoPrecompiles
        14. 32.8.3.14. assumePayable
      4. 32.8.4. Std Errors
        ❱
        1. 32.8.4.1. assertionError
        2. 32.8.4.2. arithmeticError
        3. 32.8.4.3. divisionError
        4. 32.8.4.4. enumConversionError
        5. 32.8.4.5. encodeStorageError
        6. 32.8.4.6. popError
        7. 32.8.4.7. indexOOBError
        8. 32.8.4.8. memOverflowError
        9. 32.8.4.9. zeroVarError
      5. 32.8.5. Std Storage
        ❱
        1. 32.8.5.1. target
        2. 32.8.5.2. sig
        3. 32.8.5.3. with_key
        4. 32.8.5.4. depth
        5. 32.8.5.5. checked_write
        6. 32.8.5.6. find
        7. 32.8.5.7. read
      6. 32.8.6. Std Math
        ❱
        1. 32.8.6.1. abs
        2. 32.8.6.2. delta
        3. 32.8.6.3. percentDelta
      7. 32.8.7. Script Utils
        ❱
        1. 32.8.7.1. computeCreateAddress
        2. 32.8.7.2. deriveRememberKey
      8. 32.8.8. Console Logging
    9. 32.9. DSTest Reference
  43. 33. Miscellaneous
    ❱
    1. 33.1. Struct encoding
    2. 33.2. Precompile Registry

Foundry Book

Config Reference

  • Overview
  • Project
  • Solidity Compiler
  • Testing
  • In-line test configuration
  • Formatter
  • Documentation Generator
  • Etherscan