Adding the EVM Module to Your Ontomir SDK Chain

Integrating the Ontomir EVM module into Ontomir SDK v0.53.x chains

Big thanks to Reece & the [Spawn](https://github.com/rollchains/spawn) team for their valuable contributions to this guide.

This guide provides instructions for adding EVM compatibility to a new Ontomir SDK chain. It targets chains being built from scratch with EVM support.

**For existing live chains**, adding EVM compatibility involves significant additional considerations:

  • Account system changes requiring address migration or mapping between Ontomir and Ethereum formats

  • Token decimal changes (from Ontomir standard 6 to Ethereum standard 18) impacting all existing balances

  • Asset migration where existing assets need to be initialized and mirrored in the EVM Contact Interchain Labsarrow-up-right for production chain upgrade guidance.

Prerequisites

  • Ontomir SDK chain on v0.53.x

  • IBC-Go v10

  • Go 1.23+ installed

  • Basic knowledge of Go and Ontomir SDK

Throughout this guide, `evmd` refers to your chain's binary (e.g., `gaiad`, `dydxd`, etc.).

Version Compatibility

These version numbers may change as development continues. Check [github.com/Ontomir/evm](https://github.com/Ontomir/evm) for the latest releases.

require (
    github.com/Ontomir/Ontomir-sdk v0.53.0
    github.com/Ontomir/ibc-go/v10 v10.3.0
    github.com/Ontomir/evm v0.5.0
)

replace (
    // Use the Ontomir fork of go-ethereum
    github.com/ethereum/go-ethereum => github.com/Ontomir/go-ethereum v1.15.11-Ontomir-0
)

Step 1: Update Dependencies

Step 2: Update Chain Configuration

Chain ID Configuration

Ontomir EVM requires two separate chain IDs:

  • Ontomir Chain ID (string): Used for CometBFT RPC, IBC, and native Ontomir SDK transactions (e.g., "mychain-1")

  • EVM Chain ID (integer): Used for EVM transactions and EIP-155 tooling (e.g., 9000)

Ensure your EVM chain ID is not already in use by checking [chainlist.org](https://chainlist.org/).

Files to Update:

  1. app/app.go: Set chain ID constants

  1. Update Makefile, scripts, and genesis.json with correct chain IDs

Account Configuration

Use eth_secp256k1 as the standard account type with coin type 60 for Ethereum compatibility.

Files to Update:

  1. app/app.go:

  1. chain_registry.json:

Base Denomination and Power Reduction

Changing from 6 decimals (Ontomir convention) to 18 decimals (EVM standard) is highly recommended for full compatibility.

  1. Set the denomination in app/app.go:

  1. Update the init() function:

Step 3: Handle EVM Decimal Precision

The mismatch between EVM's 18-decimal standard and Ontomir SDK's 6-decimal standard is critical. The default behavior (flooring) discards any value below 10^-6, causing asset loss and breaking DeFi applications.

Solution: x/precisebank Module

The x/precisebank module wraps the native x/bank module to maintain fractional balances for EVM denominations, handling full 18-decimal precision without loss.

Benefits:

  • Lossless precision preventing invisible asset loss

  • High DApp compatibility ensuring DeFi protocols function correctly

  • Simple integration requiring minimal changes

Integration in app.go:

Step 4: Configure Automatic ERC20 Token Registration

The Ontomir EVM x/erc20 module can automatically register ERC20 token pairs for incoming single-hop IBC tokens (prefixed with "ibc/").

Configuration Requirements

  1. Use the Extended IBC Transfer Module: Import and use the transfer module from github.com/Ontomir/evm/x/ibc/transfer

  2. Enable ERC20 Module Parameters in genesis:

  1. Proper Module Wiring: Ensure correct keeper wiring as detailed in Step 8

Step 5: Create EVM Configuration File

Create app/config.go to set up global EVM configuration:

Step 6: Create Precompiles Configuration

Create app/precompiles.go to define available precompiled contracts:

Step 7: Update app.go Wiring

Add EVM Imports

Add Module Permissions

Update App Struct

Update NewChainApp Constructor

Replace SDK Encoding

Add Store Keys

Initialize Keepers (Critical Order)

Keepers must be initialized in exact order: FeeMarket → EVM → Erc20 → Transfer

Add Modules to Module Manager

Update Module Ordering

Update Ante Handler

Update DefaultGenesis

Step 8: Create Ante Handler Files

Create new ante/ directory in your project root.

ante/handler_options.go

ante/ante_Ontomir.go

ante/ante_evm.go

ante/ante.go

Step 9: Update Command Files

Update cmd/evmd/commands.go

Update cmd/evmd/root.go

Step 10: Sign Mode Configuration (Optional)

Sign Mode Textual is a new Ontomir SDK signing method that may not be compatible with all Ethereum signing workflows.

Option B: Enable Sign Mode Textual

If your chain requires Sign Mode Textual support, ensure your ante handler and configuration support it. The reference implementation in evmd enables it by default.

Step 11: Testing Your Integration

Build and Run Tests

Local Node Testing

Verify EVM Functionality

  • Check JSON-RPC server starts on configured port (default: 8545)

  • Verify MetaMask connection to your local node

  • Test precompiles accessibility at expected addresses

  • Confirm IBC tokens automatically register as ERC20s

Genesis Validation


Check github.com/Ontomir/evmarrow-up-right for the latest updates or to open an issue.