Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Foundry is the modern toolchain — fast, written in Rust, no Node.js. Three commands: forge, cast, anvil. forge compiles and tests. cast talks to chains. anvil is a local chain that starts in a fraction of a second. Installing Foundry is a one-line curl | sh via foundryup. Once you've compiled one contract, you've cleared the biggest onboarding hurdle in smart contract development.
Foundry's forge init scaffolds a project with a src/, test/, and script/ layout and a foundry.toml config in under a second. Unlike Hardhat, it has no Node.js dependency — the compiler is bundled in Rust, so forge build is consistently 5–10× faster on large codebases.
# 1. Install foundryup (manages forge/cast/anvil versions)
curl -L https://foundry.paradigm.xyz | bash
foundryup
# 2. Create a project
forge init hello-solidity
cd hello-solidity
# 3. Replace src/Counter.sol with a hello contract
cat > src/Hello.sol <<'EOF'
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
foundryup. Verify with forge --version, cast --version, anvil --version.forge init hello-solidity. Explore the generated directory — src/, test/, script/, foundry.toml.Hello contract above. Run forge build.out/Hello.sol/Hello.json. Look at the bytecode.object field — that's the hex you'd deploy.Hello.sol and re-run forge build. Notice how incremental compilation is nearly instant.Use these three in order. Each builds on the one before.
Describe the Foundry toolchain: what `forge`, `cast`, and `anvil` each do, and how they fit together in a typical development flow.
Foundry is written in Rust. Walk me through what `forge build` actually does when it compiles a `.sol` file — parsing, AST, IR, bytecode, metadata. Where does each step happen?
Compare Foundry, Hardhat, and Brownie as development frameworks. For a serious DeFi project in 2026, which would you pick and why? Where is each one weakest?