Lesson 10 — Foundry — the Rust EVM toolchain
Question
Foundry = the Rust-native Solidity toolchain. Four binaries (forge test+build / cast chain CLI / anvil local node / chisel Solidity REPL), all using Revm internally. 20–30× faster than the JS toolchains (Hardhat / Truffle) because it's in-process.
Principle (minimum model)
- Four binaries.
forge(tests + compile) /cast(curl + jq for EVM) /anvil(local node,--fork-urlfor mainnet fork) /chisel(Solidity REPL). - Install with
foundryup.curl -L https://foundry.paradigm.xyz | bash && foundryup— one-liner; updates the whole toolchain. forge test= the Solidity-sidecargo test..t.solfiles +test*functions are auto-discovered; sub-second feedback via in-process Revm.- Cheatcodes = precompiles.
vm.warp/vm.deal/vm.prankare calls to the precompile at0x71097.... Structurally different from Hardhat'sevm_snapshot(which is JSON-RPC). - Mastering Foundry course (Intermediate). Discipline transfer (Rust proptest! → forge fuzz / forge invariant), Capstone proves
InsuranceFundin two languages. This lesson is the entry point.
Worked example + steps
Foundry — the Rust EVM toolchain (orientation)
Foundry is the Rust EVM toolchain in the same lineage as Reth / Revm / Alloy, made up of four main tools:
| Tool | Role |
|---|---|
| forge | Solidity build / test |
| cast | RPC / calldata / storage inspection |
| anvil | Local node (including fork mode) |
| chisel | Solidity REPL |
Minimal setup:
curl -L https://foundry.paradigm.xyz | bash
foundryup
forge init counter && cd counter
forge test
The one takeaway here: forge test runs on top of Revm. Foundry is not a parallel world cut off from node development — it's the developer-facing interface to the same execution engine.
Where to go next
- Full Foundry orientation:
/courses/mastering-foundry-en/lessons/foundry-orientation-en - Cheatcode internals:
/courses/mastering-foundry-en/lessons/foundry-anvil-cheatcodes-en - Production-grade test discipline (fuzz / invariant / cheatcode) lives in the main Foundry course
Test posture (minimum for this page)
Memorise three Foundry test shapes:
- unit (
forge test) - fuzz (input-space exploration)
- invariant (preservation laws across call orderings)
Minimal cycle:
forge test
forge test -vvv
forge snapshot
Pre-production minimums:
- Verify failure paths with
vm.expectRevert - Verify key events with
vm.expectEmit - Fuzz public inputs that contain arithmetic
- Enforce accounting invariants with
invariant
Beyond this page (deduplicated into the dedicated course)
- Full test discipline:
/courses/mastering-foundry-en/lessons/foundry-orientation-en - Fuzz in practice:
/courses/mastering-foundry-en/lessons/foundry-forge-fuzz-en - Invariant in practice:
/courses/mastering-foundry-en/lessons/foundry-forge-invariant-en - Cheatcode / fork in practice:
/courses/mastering-foundry-en/lessons/foundry-anvil-cheatcodes-en
Summary (3 lines)
- Foundry = Rust Solidity toolchain; four binaries (forge / cast / anvil / chisel) on Revm; 20–30× faster than Hardhat/Truffle.
forge test=cargo test-equivalent on in-process Revm. Cheatcodes are precompiles (vm.warp/vm.deal/vm.pranketc).- Mastering Foundry Intermediate course deep-dives the discipline transfer. Next: Fundamentals final quiz.