Overview
Precompiles allow EVM contracts to interact directly with native chain modules. Precompiles are special contract addresses that execute native Go code instead of EVM bytecode.All Standard EVM Precompiles
MANTRA Chain supports all standard EVM precompiles that are available on Ethereum and other EVM-compatible chains. These precompiles work identically to how they work on Ethereum, Base, Polygon, Arbitrum, and other EVM chains.Standard Ethereum Precompiles
All of the following standard EVM precompiles are available and fully functional:- ECRecover (0x01) - Elliptic curve signature recovery
- SHA256 (0x02) - SHA-256 hash function
- RIPEMD160 (0x03) - RIPEMD-160 hash function
- Identity (0x04) - Data copying function
- ModExp (0x05) - Modular exponentiation
- BN256Add (0x06) - Elliptic curve addition on the BN256 curve
- BN256Mul (0x07) - Elliptic curve scalar multiplication on the BN256 curve
- BN256Pairing (0x08) - Bilinear pairing on the BN256 curve
- Bls12-381 (0x09-0x0F) - BLS12-381 curve operations
Additional Cosmos SDK Precompiles
In addition to all standard EVM precompiles, MANTRA Chain exposes additional precompiles that let developers interact with the CosmWasm (CW) side of the chain. These precompiles enable seamless integration between EVM contracts and Cosmos SDK modules. The EVM communicates with the Cosmos part of the chain through these precompiles - Go code that directly interacts with other module states (e.g., Bank module). Precompiles are special contract addresses that execute native Go code instead of EVM bytecode, enabling seamless integration between EVM and Cosmos SDK modules.Cosmos SDK Precompiles
There are 5 Cosmos SDK precompiles exposed inside the EVM:1. Staking Precompile
Interact with the staking module directly from EVM contracts:- Delegate tokens: Delegate native tokens to validators
- Undelegate tokens: Undelegate from validators
- Redelegate tokens: Move delegation between validators
- Query delegation information: Get delegation details
- Automated staking strategies
- Liquid staking protocols
- Validator selection algorithms
2. Distribution Precompile
Manage staking rewards from EVM contracts:- Claim rewards: Claim staking rewards
- Withdraw rewards: Withdraw accumulated rewards
- Query reward information: Get reward details
- Automated reward claiming
- Reward distribution protocols
- Staking aggregators
3. Slashing Precompile
Handle slashing operations and re-staking:- Re-staking operations: Manage validator re-staking
- Reward management: Handle slashing-related rewards
- Validator penalties: Query and handle penalties
- Slashing protection protocols
- Validator health monitoring
- Risk management systems
4. Governance Precompile
Participate in on-chain governance from EVM contracts:- Vote on proposals: Cast votes on governance proposals
- Create proposals: Submit new governance proposals
- Query proposal information: Get proposal details and status
- Automated governance participation
- Governance aggregators
- Proposal creation tools
5. Bank Precompile
Transfer native Cosmos tokens from EVM contracts:- Transfer tokens: Send native tokens
- Query balances: Get token balances
- Multi-send operations: Batch token transfers
- Token bridges
- Payment protocols
- Multi-sig wallets
ERC20 Precompiles
Each TokenFactory token has its own ERC20 precompile address, allowing:- Control token balance: Manage token balances from EVM
- Transfer tokens: Transfer TokenFactory tokens
- Use tokens in EVM contracts: Seamless integration
Precompile Addresses
Precompile addresses are fixed and documented. The addresses below are examples - actual addresses will be provided in the official documentation.
Using Precompiles
Basic Pattern
Precompiles are called like regular contract calls:Example: Staking Precompile
Example: Bank Precompile
Example: Governance Precompile
TokenFactory ERC20 Precompiles
TokenFactory tokens automatically get ERC20 precompile addresses:Best Practices
Error Handling
Always check return values from precompiles:Gas Considerations
Precompiles execute native Go code, which is generally more gas-efficient than contract calls, but still consider:- Gas costs for precompile calls
- Batch operations when possible
- Optimize for frequently called functions
Security
- Validate inputs before calling precompiles
- Use access controls for precompile calls
- Test precompile interactions thoroughly
Next Steps
- Learn more about Cosmos precompiles architecture
- Understand transaction sequencing
- Explore EVM development guides