Skip to main content
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

The local_node.sh script automatically configures default preinstalls:

2. Governance Proposal

For chains already in production, use the MsgRegisterPreinstalls 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:
  1. 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)
  2. Code Validation
    • Must be valid EVM bytecode (hex encoded)
    • Cannot have empty code hash
    • Must pass bytecode verification
  3. 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

  1. Local Testing: Deploy on local node first
  2. Testnet Validation: Test governance proposal process
  3. Integration Testing: Verify interactions with other contracts
  4. Gas Analysis: Monitor gas consumption patterns
  5. 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

  1. Start with Defaults: Use evmtypes.DefaultPreinstalls unless you have specific requirements
  2. Test Thoroughly: Validate on testnet before mainnet deployment
  3. Document Changes: Clearly communicate any non-standard deployments to developers
  4. 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

Debugging Steps

  1. Check chain genesis configuration
  2. Verify proposal passed and executed
  3. Query contract code directly
  4. Test with simple contract interaction
  5. Review chain logs for errors

Further Resources