FABRKNT
Reth Fundamentals — Your First Steps with Alloy
Inside the EVM
Lesson 10 of 11·CONTENT10 min20 XP

Treat this page as a workbench, not a blog post. The goal is to extract a reusable mental model from the source and carry it into the rest of the Fabrknt stack.

Course
Reth Fundamentals — Your First Steps with Alloy
Lesson role
CONTENT
Sequence
10 / 11

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-url for 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-side cargo test. .t.sol files + test* functions are auto-discovered; sub-second feedback via in-process Revm.
  • Cheatcodes = precompiles. vm.warp / vm.deal / vm.prank are calls to the precompile at 0x71097.... Structurally different from Hardhat's evm_snapshot (which is JSON-RPC).
  • Mastering Foundry course (Intermediate). Discipline transfer (Rust proptest! → forge fuzz / forge invariant), Capstone proves InsuranceFund in 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:

ToolRole
forgeSolidity build / test
castRPC / calldata / storage inspection
anvilLocal node (including fork mode)
chiselSolidity 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:

  1. unit (forge test)
  2. fuzz (input-space exploration)
  3. 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.prank etc).
  • Mastering Foundry Intermediate course deep-dives the discipline transfer. Next: Fundamentals final quiz.