Monad-revm extends the Revm implementation with Monad-specific customizations.
| Component | Version |
|---|---|
| Revm | v34.0.0 |
| Monad Spec | MONAD_EIGHT (Prague compatible) |
Monad uses a modified gas model optimized for its execution environment:
No Gas Refunds — Users pay gas_limit × gas_price, not gas_used × gas_price.
Increased Cold Access Costs — Cold storage reads are more expensive to reflect the cost of state access from disk:
| Access Type | Ethereum | Monad |
|---|---|---|
| Cold Storage (SLOAD) | 2,100 | 8,100 |
| Cold Account (BALANCE, EXTCODE*, CALL*) | 2,600 | 10,100 |
| Warm Access | 100 | 100 |
Several precompiles are repriced to reflect their relative computational cost:
| Precompile | Address | Ethereum | Monad | Multiplier |
|---|---|---|---|---|
| ecRecover | 0x01 | 3,000 | 6,000 | 2x |
| ecAdd | 0x06 | 150 | 300 | 2x |
| ecMul | 0x07 | 6,000 | 30,000 | 5x |
| ecPairing | 0x08 | 45,000 + 34,000/pt | 225,000 + 170,000/pt | 5x |
| blake2f | 0x09 | rounds × 1 | rounds × 2 | 2x |
| KZG point eval | 0x0a | 50,000 | 200,000 | 4x |
Staking Precompile — monad-revm provides read-only access to Monad's native staking state at address 0x1000:
| Method | Selector | Gas |
|---|---|---|
getEpoch() |
0x757991a8 | 16,200 |
getProposerValId() |
0xfbacb0be | 100 |
getValidator(uint64) |
0x2b6d639a | 97,200 |
getDelegator(uint64,address) |
0x573c1ce0 | 184,900 |
getWithdrawalRequest(uint64,address,uint8) |
0x56fa2045 | 24,300 |
getConsensusValidatorSet(uint32) |
0xfb29b729 | 2,100 + 2,100/elem |
getSnapshotValidatorSet(uint32) |
0xde66a368 | 2,100 + 2,100/elem |
getExecutionValidatorSet(uint32) |
0x7cb074df | 2,100 + 2,100/elem |
getDelegations(address,uint64) |
0xa6a7301c | 814,000 |
getDelegators(uint64,address) |
0x48e327d0 | 814,000 |
| Limit | Ethereum | Monad |
|---|---|---|
| Max code size | 24KB | 128KB |
| Max initcode size | 48KB | 256KB |
Blob Transactions Rejected — EIP-4844 blob transactions return Eip4844NotSupported.
Add to your Cargo.toml:
[dependencies]
monad-revm = { git = "https://github.com/category-labs/monad-revm", branch = "main" }Or from crates.io:
[dependencies]
monad-revm = "0.1"use monad_revm::{MonadBuilder, DefaultMonad};
use revm::{
context::{Context, TxEnv},
database::InMemoryDB,
ExecuteEvm,
};
// Create a Monad EVM context
let ctx = Context::monad();
let mut evm = ctx.build_monad();
// Execute a transaction
let tx = TxEnv::builder()
.caller(caller_address)
.to(contract_address)
.value(U256::from(1000))
.gas_limit(100_000)
.gas_price(1_000_000_000)
.build_fill();
let result = evm.transact(tx).expect("Transaction failed");use monad_revm::{MonadBuilder, DefaultMonad};
use revm::{context::Context, inspector::NoOpInspector};
let ctx = Context::monad();
let mut evm = ctx.build_monad_with_inspector(NoOpInspector {});use monad_revm::{MonadBuilder, DefaultMonad};
use revm::context::Context;
let db = MyCustomDatabase::new();
let ctx = Context::monad().with_db(db);
let mut evm = ctx.build_monad();monad-revm/
├── crates/
│ └── monad-revm/
│ └── src/
│ ├── lib.rs # Re-exports
│ ├── spec.rs # MonadSpecId hardfork enum
│ ├── cfg.rs # MonadCfgEnv
│ ├── handler.rs # MonadHandler
│ ├── instructions.rs # Custom gas parameters
│ ├── precompiles.rs # Repriced precompiles
│ ├── evm.rs # MonadEvm type alias
│ ├── api/
│ │ ├── builder.rs # MonadBuilder trait
│ │ ├── exec.rs # MonadContextTr trait
│ │ └── default_ctx.rs # DefaultMonad extension
│ └── staking/
│ ├── mod.rs # Staking precompile dispatcher
│ ├── abi.rs # Gas constants
│ ├── interface.rs # Solidity ABI definitions
│ ├── storage.rs # Storage slot calculations
│ └── types.rs # Validator, Delegator, etc.
└── Cargo.toml
MonadSpecId — Hardfork identifier. Currently only MonadEight (based on Prague).
MonadHandler — Implements Monad's gas model.
MonadPrecompiles — Provides repriced Ethereum precompiles plus P256VERIFY and the staking precompile.
monad_gas_params() — Returns gas parameters with Monad's cold access costs.
serde— Enable serialization forMonadSpecIdalloy-evm— Enable integration withalloy_evm::precompiles::PrecompilesMapfor Foundry/Anvil
See monad-foundry for the complete Foundry integration.
- revm — Base Ethereum Virtual Machine
- alloy-monad-evm — Alloy EVM wrapper for monad-revm
- monad-foundry — Foundry fork with Monad support
Revm is licensed under MIT License.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in these crates by you, shall be licensed as above, without any additional terms or conditions.