Skip to content
Monpediaby Unity Nodes
Monad Docstooling and infra › toolkits › foundry

Foundry

From docs.monad.xyz/tooling-and-infra/toolkits/foundryUpdated Nov 19, 2026read Nov 19, 2026

Contents8 sections

Use Foundry to build, test, deploy, and debug contracts with the Monad execution environment.

Foundry v1.8 or later includes first-class Monad execution support across Forge, Anvil, Cast, Chisel, traces, and cheatcodes. Use the official Foundry distribution for Monad development.

For general Foundry usage, including writing tests and scripts, deployment, configuration, and cheatcodes, refer to the Foundry documentation.

Installation

Install the official Foundry installer:

curl -L https://foundry.paradigm.xyz | bash

Follow the installer instructions to add foundryup to your shell, then install the latest stable Foundry release:

foundryup

Confirm that you are running Foundry v1.8.0 or later:

forge --version

Foundry releases before v1.8 do not include Monad execution support.

Configure Monad execution

Set the execution network in your project's foundry.toml:

[profile.default]
network = "monad"

This setting makes local Forge, Cast, and Chisel execution use Monad's gas model, opcode pricing, transaction rules, precompiles, and contract size limits.

You can select Monad for a single command instead:

forge test --network monad

Hardfork selection

Local Monad execution defaults to the latest supported Monad hardfork, currently MonadTen. To reproduce an earlier hardfork, set it explicitly:

[profile.default]
network = "monad"
hardfork = "monad:MonadNine"

You can also select a hardfork for a single command:

forge test --network monad --hardfork MonadNine

When Foundry forks Monad Mainnet or Testnet, it uses the endpoint's chain ID and the forked block's timestamp to select the active Monad hardfork automatically.

Monad execution features

Feature Description
Monad EVM execution Monad gas model, opcode pricing, transaction rules, 128 KB contract size limit, and 256 KB initcode size limit
Monad hardforks Explicit hardfork selection and automatic selection for historical and live network forks
MonadTen and MIP-8 Page-based storage access, write, and state-growth gas accounting
Monad precompiles Monad precompile execution, staking cheatcodes, and human-readable trace decoding
Anvil with Monad Local or forked Monad execution using the official Anvil binary
Contract verification Monad-aware bytecode replay for Forge verification workflows

For the complete list of protocol differences, see Differences between Monad and Ethereum.

Anvil

Use --network monad to start a local Anvil node with the Monad execution environment:

anvil --network monad

Anvil defaults to MonadTen for new local chains. You can also fork Monad Testnet or Mainnet:

# Fork Monad Testnet
anvil --fork-url https://testnet-rpc.monad.xyz

# Fork Monad Mainnet
anvil --fork-url https://rpc.monad.xyz

When forking a canonical Monad endpoint, Anvil detects the Monad network from its chain ID and selects the active hardfork for the fork block.

Cast and Chisel

Cast and Chisel use the Monad execution environment when network = "monad" is set in foundry.toml. You can also pass --network monad directly to supported commands.

All standard Cast and Chisel workflows remain available. Monad-specific precompile calls are decoded in traces with human-readable names and parameters.

CI integration

Use the official Foundry toolchain action and install v1.8.0 or later:

- name: Install Foundry
  uses: foundry-rs/foundry-toolchain@v1
  with:
    version: v1.8.0

For example:

name: CI

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          submodules: recursive

      - name: Install Foundry
        uses: foundry-rs/foundry-toolchain@v1
        with:
          version: v1.8.0

      - name: Run tests with Monad execution
        run: forge test --network monad -vvv

Migrating from Monad Foundry

The legacy Monad Foundry fork supports Monad execution only through the MonadNine hardfork. It does not support MonadTen or MIP-8 and should be migrated from.

To migrate:

  1. Install Foundry v1.8 or later with the official installer and run foundryup.
  2. Add network = "monad" to your foundry.toml, or pass --network monad to individual commands.
  3. Replace anvil --monad with anvil --network monad.
  4. Replace category-labs/foundry-toolchain@v1 with foundry-rs/foundry-toolchain@v1 in CI.
  5. Remove scripts that install Foundry from foundry.category.xyz or run foundryup --network monad.

The official release includes the Monad execution behavior, precompiles, trace decoding, and tooling integration previously provided by the fork, along with MonadTen support.