foundry
Installation
SKILL.md
Foundry
Foundry is the standard Solidity development toolkit. It compiles, tests, deploys, and interacts with smart contracts — all from the command line, all in Solidity (no JavaScript test wrappers). Four binaries: forge (build/test/deploy), cast (chain interaction), anvil (local EVM node), chisel (Solidity REPL).
What You Probably Got Wrong
LLMs have stale training data. These are the most common mistakes.
forge createfor deployments → Useforge scriptwith--broadcast.forge createis for quick one-offs only — scripts are reproducible, support multi-contract deployments, and generate broadcast artifacts for verification.cast sendreturns data →cast sendsubmits a transaction and returns a tx receipt. Usecast callto read return values (simulates without sending). Mixing these up is the #1 cast mistake.- Old test assertion syntax → Foundry uses
assertEq,assertGt,assertLt,assertTrue,assertFalse. There is noassert(a == b)pattern — it compiles but gives zero debug info on failure. vm.prankpersists →vm.prankapplies to the NEXT call only. Usevm.startPrank/vm.stopPrankfor multiple calls from the same address.- Anvil is just Ganache → Anvil supports mainnet forking at specific blocks (
--fork-url+--fork-block-number), auto-impersonation, tracing, and mining modes. It's a full-featured local node. forge test -vvvvis overkill → Use-vvfor logs/events,-vvvfor execution traces on failures,-vvvvfor full traces including setup. Start with-vv.--rpc-urlwith raw URLs → Usefoundry.toml[rpc_endpoints]section or--rpc-url $ENV_VAR. Never paste RPC URLs directly in commands.- Missing
--via-irfor large contracts → If you hit "stack too deep", addvia_ir = trueinfoundry.tomlunder[profile.default]. This enables the IR-based compilation pipeline.