Chapter 10
Foundry Workflow
Foundry bundles compilation, testing, scripting, and chain interaction into one fast toolchain. forge replaces separate compile-and-test runners, cast handles low-level RPC calls, and anvil gives you a local mainnet fork or fresh chain in seconds.
Use .env files for RPC URLs and private keys, loaded via forge script --account or vm.envUint in tests. Never commit secrets — .gitignore them and inject via CI secrets for automated deploys.
Fork tests let you simulate against live mainnet state: deploy your contract, interact with real Uniswap pools, and verify behavior against production conditions without spending real ETH on experiments.