> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monad.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Monad Foundry

[Monad Foundry](https://github.com/category-labs/foundry/tree/monad) is a custom fork of [Foundry](https://book.getfoundry.sh/) that integrates Monad features directly into the familiar Foundry developer workflow. It uses [monad-revm](https://github.com/category-labs/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](https://book.getfoundry.sh/).

## Installation

Install the Monad Foundry installer:

```sh theme={null}
curl -L https://foundry.category.xyz | bash
```

Then install Monad Foundry:

```sh theme={null}
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.
</Note>

## Features

| Feature                   | Description                                                                    |
| ------------------------- | ------------------------------------------------------------------------------ |
| **Monad EVM Execution**   | Monad gas model, 128KB code size limit, no gas refunds, repriced precompiles   |
| **Staking Precompile**    | All staking view functions work locally at address `0x1000`                    |
| **Human-Readable Traces** | Staking calls decoded with function names; address labeled "Staking" in traces |
| **Anvil with Monad**      | `anvil --monad` for a local Monad EVM node                                     |
| **Contract Verification** | `forge 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](/developer-essentials/gas-pricing) for details.
* **Contract size**: Max contract size is 128KB
* **Initcode size**: Max initcode size is 256KB
* **Precompile gas costs**: See [Opcode Pricing](/developer-essentials/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](/developer-essentials/differences).

## Staking Precompile Support

All [staking precompile](/reference/staking/api) 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:

```sh theme={null}
# 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.

## CI Integration

Use the [Monad Foundry GitHub Action](https://github.com/category-labs/foundry-toolchain) to install Monad Foundry in your CI workflows:

```yaml theme={null}
- name: Install Monad Foundry
  uses: category-labs/foundry-toolchain@v1
```

This installs the latest stable Monad Foundry (`stable-monad`) by default. You can also pin a specific version:

```yaml theme={null}
- name: Install Monad Foundry
  uses: category-labs/foundry-toolchain@v1
  with:
    version: v1.5.0-monad.0.1.0
```

Full workflow example:

```yaml theme={null}
name: CI

on: [push, pull_request]

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

      - name: Install Monad Foundry
        uses: category-labs/foundry-toolchain@v1

      - name: Run tests
        run: forge test -vvv
```

The action supports caching and works on all platforms (Linux, macOS, Windows). See the [foundry-toolchain repo](https://github.com/category-labs/foundry-toolchain) for all available options.

## 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](https://github.com/category-labs/foundry/releases) for full release history.
