For conceptual understanding of predeployed contracts and how they differ from precompiles, see the Predeployed Contracts concept page.
Activation Methods
There are three primary methods to deploy preinstalled contracts on a Cosmos EVM chain:1. Genesis Configuration
The most straightforward method for new chains or testnets. Contracts are deployed when the chain is first initialized.Default Configuration
Using the evmd example application automatically includes default preinstalls:Custom Genesis Configuration
To customize which contracts are deployed:Local Development
Thelocal_node.sh
script automatically configures default preinstalls:
2. Governance Proposal
For chains already in production, use theMsgRegisterPreinstalls
governance proposal:
Proposal Structure
The
authority
field must be set to the governance module account address, which is typically derived from the gov module name. This is usually something like cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn
for the standard gov module.Submission Process
3. Chain Upgrade Handler
Include predeployed contracts as part of a coordinated chain upgrade:Implementation Details
Validation Process
All preinstall deployments undergo strict validation:-
Address Validation
- Must be valid Ethereum address format (40 hex characters)
- Cannot conflict with existing contracts
- Should not overlap with precompile reserved addresses (typically 0x1-0x9FF)
-
Code Validation
- Must be valid EVM bytecode (hex encoded)
- Cannot have empty code hash
- Must pass bytecode verification
-
Conflict Prevention
- Checks for existing contracts at target address
- Validates against account keeper for existing accounts
- Ensures no code hash conflicts with different bytecode
Storage and State
Predeployed contracts are stored in the chain state like regular contracts:Verification and Testing
Verify Deployment
After deployment, verify contracts are properly installed:Testing Strategy
- Local Testing: Deploy on local node first
- Testnet Validation: Test governance proposal process
- Integration Testing: Verify interactions with other contracts
- Gas Analysis: Monitor gas consumption patterns
- Security Audit: Review bytecode before mainnet deployment
Best Practices
Security Considerations
- Bytecode Verification: Always verify that bytecode matches official releases
- Address Selection: Ensure addresses don’t conflict with future plans
- Audit Requirements: Even well-known contracts should be reviewed
- Immutability: Remember that predeployed contracts cannot be upgraded
Deployment Recommendations
- Start with Defaults: Use
evmtypes.DefaultPreinstalls
unless you have specific requirements - Test Thoroughly: Validate on testnet before mainnet deployment
- Document Changes: Clearly communicate any non-standard deployments to developers
- Monitor Usage: Track contract interactions to understand adoption
Common Pitfalls to Avoid
- Don’t deploy to addresses that could conflict with precompiles (typically 0x1-0x9FF)
- Don’t assume contracts are deployed - always check first
- Don’t modify standard contract addresses without strong justification
- Don’t deploy untested or unaudited bytecode
Known Issues
The Safe Singleton Factory bytecode in the current DefaultPreinstalls may be incorrect (appears to be duplicate of Create2 bytecode). Verify the correct bytecode before deploying this contract in production.
Adding Custom Preinstalls
To add custom contracts beyond the defaults:Troubleshooting
Common Issues
Issue | Cause | Solution |
---|---|---|
”preinstall already has an account in account keeper” | Address collision | Choose different address |
”preinstall has empty code hash” | Invalid or empty bytecode | Verify bytecode hex string is valid |
”preinstall address is not a valid hex address” | Malformed address | Ensure 0x prefix and 40 hex chars |
”invalid authority” | Wrong governance address | Use correct gov module account address |
Contract not found after deployment | Wrong network | Verify chain ID and RPC endpoint |
Debugging Steps
- Check chain genesis configuration
- Verify proposal passed and executed
- Query contract code directly
- Test with simple contract interaction
- Review chain logs for errors
Further Resources
- EIP-1014: CREATE2 Specification - Understanding deterministic deployment
- Multicall3 Documentation - Official Multicall3 repository
- Permit2 Introduction - Uniswap’s Permit2 design
- Safe Contracts - Safe multisig implementation