API Reference

The command surface a Solidity developer touches daily.

Path: api-reference

Third-party documentation. This is independently authored analysis of the public Foundry codebase — not the official docs, and not reviewed or endorsed by the Foundry team.

API Reference

Foundry's public surface is its CLI plus the cheatcode interface. The essentials:

Forge

  • forge build — compile; artifacts land in out/, caches in cache/.
  • forge test — run tests. --match-contract/--match-test filter by regex; -vvvv adds full traces with decoded calls.
  • forge script — simulate (default) or broadcast (--broadcast) a scripted flow.
  • forge create / forge verify-contract — direct deployment and Etherscan-style verification.

Cast

  • cast call <addr> <sig> [args] — eth_call with inline-ABI decoding.
  • cast send — state-changing transaction from a keystore or private key.
  • cast wallet — keystore management, signatures, addresses.
  • cast 4byte <selector> — selector lookup against signature databases.

Anvil

  • anvil — start a dev chain with deterministic funded accounts.
  • anvil --fork-url <url> — fork a live network at latest or a pinned block.
  • Special methods: anvil_setBalance, anvil_impersonateAccount, evm_snapshot/evm_revert for stateful test orchestration over RPC.

Cheatcodes

The Vm interface (from forge-std) groups cheatcodes by domain: prank/startPrank, warp/roll, deal, expectCall/expectRevert, mockCall, ffi, snapshotState. Each is documented in the forge-std source, which doubles as the canonical reference.

Interface

Interface
text
forge build [--retries N] # compile the project
forge test [-vvv] [--match-test PAT] # run tests; -vvvv shows full traces
forge script Script --rpc-url URL # execute/broadcast a scripted flow
cast call ADDR SIG [ARGS] [--rpc-url URL] # read-only RPC call
cast send ADDR SIG [ARGS] [--private-key K] # state-changing transaction
cast 4byte SELECTOR # resolve a function selector
anvil [--fork-url URL] [--block-time S] # local devnet / fork
 
STATUSinterface