Skip to main content

Monad Foundry

Monad Foundry is a custom fork of Foundry that integrates Monad features directly into the familiar Foundry developer workflow. It uses monad-revm, to ensure that forge test, forge script, cast, anvil, and chisel all execute with Monad's gas model, opcode pricing, and precompile behavior — so your local development environment matches Monad's on-chain behavior.

For general Foundry usage (writing tests, scripts, deployments, configuration, cheatcodes), refer to the Foundry Docs.

Installation

Install the Monad Foundry installer:

curl -L https://raw.githubusercontent.com/category-labs/foundry/monad/foundryup/install | bash

Then install Monad Foundry:

foundryup --network monad

This installs all four binaries — forge, cast, anvil, and chisel — with Monad support.

note

The same installer also supports standard Foundry. Running foundryup without --network monad will install the official upstream Foundry release, so you can use both side by side.

Features

FeatureDescription
Monad EVM ExecutionMonad gas model, 128KB code size limit, no gas refunds, repriced precompiles
Staking PrecompileAll staking view functions work locally at address 0x1000
Human-Readable TracesStaking calls decoded with function names; address labeled "Staking" in traces
Anvil with Monadanvil --monad for a local Monad EVM node
Contract Verificationforge verify-contract uses Monad EVM for bytecode comparison

Monad EVM Execution

forge test and forge script execute with Monad EVM by default. The following differences from Ethereum are applied automatically:

  • Gas charging: Gas is charged based on gas_limit, not gas_used. There are no gas refunds. See Gas Pricing for details.
  • Contract size: Max contract size is 128KB
  • Initcode size: Max initcode size is 256KB
  • Precompile gas costs: See Opcode Pricing.
  • No blob transactions: EIP-4844 (type 3) transactions are not supported.

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

Staking Precompile Support

All staking precompile view functions work in forge test at address 0x1000:

Trace Decoding

When running tests with verbose output (forge test -vvvv), staking calls are decoded with human-readable function names and parameters. The address 0x1000 is labeled as "Staking" in trace output.

All staking state-changing functions (addValidator, delegate, undelegate, withdraw, compound, claimRewards, changeCommission, externalReward) and events (ValidatorRewarded, Delegate, Undelegate, Withdraw, ClaimRewards, CommissionChanged, EpochChanged, ValidatorStatusChanged) are decoded in traces.

Example trace output:

├─ [16200] Staking::getEpoch()
│ └─ ← [Return] 42, false

Anvil with Monad EVM

Use anvil --monad to run a local development node with Monad EVM:

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

Monad EVM activates automatically when forking a Monad RPC endpoint (detected via chain ID), so you don't need the --monad flag when forking.

Cast & Chisel

cast and chisel execute with Monad EVM by default. All standard commands work the same as upstream Foundry.

Releases & Versioning

Monad Foundry uses a v{upstream}-monad.{monad_version} versioning scheme. For example, v1.5.0-monad.0.1.0 is based on upstream Foundry v1.5.0 with Monad fork version 0.1.0.

See the GitHub Releases for full release history.