VM Module Reference
The VM module (x/vm
) is the core EVM implementation that enables Ethereum compatibility on Cosmos chains. It provides the EVM runtime, state management, precompiled contracts, and transaction processing.
Module Overview
Purpose: Execute Ethereum smart contracts and process EVM transactions within the Cosmos SDK framework Key Functionality:- EVM state transitions and transaction execution
- Ethereum fork activation management (Homestead, Berlin, London, Shanghai, Cancun, Prague, etc.)
- Native precompiled contracts for Cosmos module access
- EVM-to-Cosmos and Cosmos-to-EVM account bridging
- Gas metering and fee handling
- Historical state queries with configurable retention
Configuration Methods
The VM module can be configured through genesis.json before chain launch. Here are the three primary methods:Method 1: Direct JSON Editing
Edit~/.evmd/config/genesis.json
directly:
Method 2: Using jq Command-Line Tool
Programmatically modify genesis using jq (as seen in local_node.sh):Method 3: Using genesis CLI Commands
Some parameters can be set through CLI commands (though most VM params require genesis.json editing):Parameters
evm_denom
What It Does: Specifies which bank module denomination to use as the native EVM token (gas token). Type:string
Valid Values: Must match a base denomination from bank metadata configuration
Default: "uatom"
(params.go:21)
Configuration:
- MUST match
bank.denom_metadata[0].base
- MUST match
staking.params.bond_denom
- MUST match
mint.params.mint_denom
"atest"
- For 18 decimal token (atto prefix: 10^18)"ustake"
- For 6 decimal token (micro prefix: 10^6)
- Mismatch with bank metadata causes EVM transactions to fail
- Wrong decimal places leads to incorrect balance displays
extra_eips
What It Does: Enables additional Ethereum Improvement Proposals beyond the default fork activations. Type:[]int64
(array of EIP numbers)
Valid Values: Any activatable EIP number
Default: []
(empty - all EIPs come from chain_config fork configuration) (params.go:22)
Configuration:
EIP | Description | Typical Use Case |
---|---|---|
3855 | PUSH0 instruction | Gas optimization for contracts |
2200 | Net gas metering for SSTORE | Reduces gas costs |
2929 | Gas cost increases for state access | Security hardening |
3198 | BASEFEE opcode | EIP-1559 base fee queries |
3529 | Reduction in refunds | Gas accounting changes |
- Enables opcodes/features not in your default fork configuration
- Useful for testing upcoming Ethereum features
- Can break compatibility if not carefully managed
active_static_precompiles
What It Does: List of precompiled contract addresses to enable for Cosmos module access from EVM. Type:[]string
(array of hex addresses)
Valid Values: Addresses from the available precompiles list (precompiles.go:4-15)
Default: []
(empty - no precompiles enabled) (params.go:23)
Configuration:
Address | Name | Module | Description |
---|---|---|---|
0x0100 | P256 | Cryptography | P256 elliptic curve operations |
0x0400 | Bech32 | Addressing | Convert between Bech32 and hex addresses |
0x0800 | Staking | x/staking | Delegate, undelegate, redelegate operations |
0x0801 | Distribution | x/distribution | Claim staking rewards, set withdrawal address |
0x0802 | ICS20 | IBC Transfer | IBC token transfers via EVM |
0x0803 | Vesting | x/vesting | Vesting account operations |
0x0804 | Bank | x/bank | Native Cosmos token transfers |
0x0805 | Gov | x/gov | Submit and vote on governance proposals |
0x0806 | Slashing | x/slashing | Query validator slashing info |
- Enable only needed precompiles for security and gas efficiency
- Commonly enabled: 0x0100 (P256), 0x0400 (Bech32), 0x0800 (Staking), 0x0804 (Bank)
- IBC chains: Also enable 0x0802 (ICS20)
- Governance participation: Enable 0x0805 (Gov)
evm_channels
What It Does: Whitelisted IBC channel IDs that the ICS20 precompile can use for token transfers. Type:[]string
(array of channel IDs)
Valid Values: Channel IDs matching format channel-{N}
where N is a non-negative integer
Default: []
(empty - no channels whitelisted) (params.go:24)
Configuration:
- Restricts which IBC channels the ICS20 precompile (0x0802) can transfer tokens through
- Empty list means ICS20 precompile cannot perform any IBC transfers
- Provides security control over cross-chain token movements
- Only needed if you enable ICS20 precompile (0x0802)
- Set after establishing IBC connections with other chains
- Update via governance when adding new IBC routes
access_control
What It Does: Defines permission model for contract deployment (CREATE/CREATE2) and contract calls. Type: Object withcreate
and call
fields, each containing access_type
and optional access_control_list
Valid Values:
- access_type:
0
(Permissionless),1
(Restricted),2
(Permissioned) - access_control_list: Array of addresses (only used with Restricted or Permissioned)
- Anyone can perform the operation
- Standard Ethereum behavior
- Recommended for public chains
- Everyone EXCEPT addresses in access_control_list can perform operation
- Blacklist model
- Useful for blocking specific malicious actors
- ONLY addresses in access_control_list can perform operation
- Whitelist model
- Useful for private/consortium chains or phased launches
- Controls who can deploy contracts (important for chain security)
- Controls who can call existing contracts (rarely restricted)
- Can be updated via governance proposals after launch
history_serve_window
What It Does: Number of recent blocks to keep for historical EVM queries (eth_getBlockByNumber, eth_getLogs, etc.). Type:uint64
Valid Values: Any non-negative integer
Default: 8192
blocks (params.go:50)
Configuration:
- Larger window = more disk space required
- Smaller window = less disk space usage
- Each block stores EVM state diffs and receipts
- Queries beyond history_serve_window will fail
- Block explorers need sufficient history for user queries
- DeFi analytics may require longer history
- Very large windows can slow down state pruning
- Affects database size and sync time
8192
- Default (roughly 11 hours at 5s blocks)100000
- Extended history (roughly 5.8 days at 5s blocks)1000000
- Full history (roughly 58 days at 5s blocks)0
- No history retention (not recommended for RPC nodes)
- Archive Nodes: Set to very large number or 0 (unlimited)
- RPC Nodes: 100,000 - 1,000,000 blocks
- Validator Nodes: Can use default 8192 (validators don’t serve RPC)
extended_denom_options
What It Does: Enables 18-decimal EVM representation for non-18-decimal Cosmos tokens. Required for 6-decimal tokens like ustake. Type:[]ExtendedDenomOption
- Array of objects mapping Cosmos denoms to EVM extended denoms
Valid Values: Each entry must have a valid denom pair following the extended denom pattern
Default: []
(empty - no extended denoms) (params.go:25)
Configuration:
- 18 decimals: NOT required - standard bank module works
- 6 decimals: REQUIRED - must add extended_denom_options
- Other decimals: REQUIRED - must add extended_denom_options
u
prefix (micro, 10^6) →a
prefix (atto, 10^18):ustake
→astake
n
prefix (nano, 10^9) →a
prefix (atto, 10^18):ntoken
→atoken
- Any other → add
evm
prefix:stake
→evmstake
- Native 6-decimal token:
ustake
(smallest unit) - Extended 18-decimal representation:
astake
(for EVM) - 1 ustake = 10^12 astake
- PreciseBank module handles fractional conversions
Complete Configuration Example
Based on local_node.sh:Related Documentation
- Building Your Chain Guide - Main configuration walkthrough
- Chain Customization Checklist - Complete parameter checklist
- Token Configuration Guide - Token decimals and evm_denom setup
- Fee Market Module - EIP-1559 fee configuration
- local_node.sh - Reference implementation
Source Code References
- Module Implementation: x/vm
- Parameter Types: x/vm/types/params.go
- Precompile Addresses: x/vm/types/precompiles.go
- Chain Config: x/vm/types/chain_config.go
- Genesis Setup: local_node.sh