How EVM Communicates with Cosmos
The EVM communicates with the Cosmos part of the chain through 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
Using Precompiles
Precompiles are called like regular contract calls in Solidity:Precompile Addresses
Precompile addresses are fixed and documented. See Using Precompiles for detailed addresses and interfaces.Benefits of Precompiles
- Direct Cosmos Integration: Access Cosmos SDK features from EVM
- No Wrapping Required: Use native Cosmos tokens directly
- Atomic Operations: Precompile calls are part of the transaction
- Gas Efficient: Native Go code execution is more efficient than contract calls
Next Steps
- Learn how to use precompiles in your contracts
- Understand transaction sequencing
- Explore ERC-20 token creation