Foundry Framework

Foundry is a Rust-based Ethereum smart contract development framework built by Paradigm — the integrated successor to dapptools that has become the dominant professional development environment for Solidity engineers, offering dramatically faster compilation and testing speeds than JavaScript-based alternatives while enabling contracts to be tested entirely in Solidity rather than JavaScript or TypeScript. Foundry’s design philosophy centers on Solidity-native development: tests are written in Solidity, deployed and run in a Forge-managed EVM without any JavaScript runtime overhead. This approach provides development parity (tests run in the exact environment that production contracts run in) and eliminates the friction of maintaining JS/TS test tooling alongside Solidity contract code. Foundry compiles a large contract test suite in seconds vs. minutes for equivalent Hardhat setups — the performance difference comes from Rust’s native compilation speed vs. Node.js JavaScript execution overhead. The toolkit comprises four tools: Forge (compile, test, deploy), Cast (read/write to any EVM chain via CLI), Anvil (local EVM node with forking support), and Chisel (interactive Solidity REPL for rapid prototyping).


The Four Tools

The following sections cover this in detail.

Forge — Test & Deploy

forge build # compile contracts

forge test # run all tests in test/

forge test -vvv # verbose: show logs, traces

forge test –match-test testFuzz # filter to specific test

forge create –rpc-url $RPC src/MyContract.sol:MyContract # deploy

forge script script/Deploy.s.sol –broadcast # deployment scripts

“`

Cast — CLI Chain Interaction

cast call 0xContract “balanceOf(address)” 0xAddress # read contract

cast send 0xContract “transfer(address,uint256)” 0xAddr 100 # write

cast receipt 0xTxHash # get transaction receipt

cast code 0xContract # get deployed bytecode

cast storage 0xContract 0 # read storage slot 0

cast run 0xTxHash # replay transaction with trace

“`

Anvil — Local Node

anvil # start local node (port 8545)

anvil –fork-url $ETH_RPC # fork mainnet locally

anvil –fork-block-number 18000000 # fork at specific block

“`

Chisel — Solidity REPL

chisel

# Interactive Solidity environment

# Instantly execute Solidity expressions

# Useful for prototyping function logic

“`


Configuration (foundry.toml)

“`toml

[profile.default]

src = “src” # contract directory

test = “test” # test directory

out = “out” # compilation artifacts

libs = [“lib”] # dependencies (git submodules)

solc = “0.8.19” # Solidity version

optimizer = true

optimizer_runs = 200

fuzz.runs = 256 # fuzz iterations per test

invariant.runs = 100 # invariant test campaigns

“`


vs. Hardhat

Feature Foundry Hardhat
Language Rust Node.js
Tests written in Solidity JavaScript/TypeScript
Compile speed Very fast (seconds) Moderate (10s-minutes)
Test execution Very fast Moderate
Plugin ecosystem Smaller but growing Extensive
Scripting Solidity scripts JS/TS
Learning curve Lower for Solidity devs Lower for JS devs
Industry adoption Preferred by auditors Still widely used

Related Terms


Sources

  1. “Foundry Book: The Foundry Development Framework” — Paradigm / Foundry Team (2021-2023). The official Foundry documentation covering all aspects of the toolkit — forge test framework, cheatcodes, fuzz testing, invariant testing, deployment scripts, cast usage, and anvil configuration.
  1. “Foundry vs. Hardhat: Benchmarks and Developer Experience Comparison” — Alchemy / Developer Survey (2022-2023). Comparative benchmarks and developer experience analysis between Foundry and Hardhat — covering compile times, test execution speed, debugging capabilities, deployment workflows, and which framework is preferred by professional Solidity engineers and auditors.
  1. “Cheatcodes: How Foundry Enables Solidity-Native Test Utilities” — Paradigm Engineering (2022). Technical explanation of how Foundry’s cheatcode system works — how the Forge EVM intercepts calls to a magic address and injects test utilities like vm.prank(), vm.deal(), and vm.expectRevert() into the Solidity test execution context without any compiler modifications.
  1. “Anvil: Foundry’s Local Ethereum Node with Fork Capabilities” — Paradigm / Foundry Documentation (2022). Documentation and analysis of Anvil — Foundry’s local Ethereum node that supports mainnet forking, state manipulation, and configurable block production — comparing it to Hardhat Network and Ganache for local development and integration testing.
  1. “Foundry Scripting: Solidity Deployment Scripts” — Paradigm / Smart Contract Security Practices (2023). Analysis of Foundry’s forge script system for deployment — comparing Solidity-native deployment scripts to Hardhat’s JavaScript deployments, examining the broadcast mechanism, Etherscan verification integration, and best practices for production deployment pipelines.