Skip to main content
Foundry v1.8.4 and later run Base natively in forge, cast, anvil, and chisel, including Base’s hardforks and native precompiles: the B20 token factory, B20 tokens, the PolicyRegistry, and the ActivationRegistry. Foundry v1.9.0 and later also run the Denim upgrade, which is live on Base Mainnet and Base Sepolia.
Foundry versions before v1.8.4 do not implement Base’s precompiles. Their addresses hold no contract bytecode, so a call to them reverts in a local test or simulation. Run forge --version and upgrade if it reports an earlier version.

Install

Install or upgrade to the latest stable Foundry:
Terminal
To pin a version, run foundryup --install <version>, for example foundryup --install v1.9.0.

Enable Base

Foundry runs Ethereum by default. How you turn on Base depends on where the code executes: To enable Base for every command in a project, add the hardfork to foundry.toml:
foundry.toml
Set the hardfork explicitly. --network base without --hardfork runs forge on the Azul upgrade, which predates the B20 and PolicyRegistry precompiles, so calls to them revert. As of v1.9.0, Foundry’s built-in Base upgrade schedule ends at Beryl, so a fork of Base Mainnet also runs Beryl rules unless you pass --hardfork base:Denim.

Pick a Base Upgrade

The hardfork value selects which Base upgrade’s rules and precompiles Foundry runs. Use the upgrade that is live on the network you target; see the network upgrades schedule.

base-anvil

base-anvil is Base’s fork of Foundry. It installs base-forge, base-cast, base-anvil, and base-chisel alongside stock Foundry and enables Base precompiles by default. Pin a release with base-foundryup --install <version>. The B20 issuance guides’ samples still target base-anvil v1.1.1 and use base-cast. Those commands call a live Base RPC, so they also run unchanged with cast from Foundry v1.8.4 or later. For new projects, use Foundry v1.9.0 or later.

Next Steps

Deploy a Smart Contract

Deploy a contract to Base Sepolia with Foundry, end to end.

B20 Token Standard

Launch Base’s native token standard from the command line.