The x/ibc module from cosmos/evm implements Inter-Blockchain Communication (IBC) protocol support with specialized EVM callback functionality for cross-chain smart contract interactions.

Overview

The IBC module extends the standard IBC protocol with EVM-specific features:
  • IBC Callbacks: Execute EVM contracts automatically during IBC packet lifecycle
  • Cross-chain Contract Calls: Enable smart contracts to interact across chains
  • Packet Lifecycle Management: Handle acknowledgments and timeouts through EVM contracts

Components

IBC Callbacks

The EVM Callbacks module implements the EVM contractKeeper interface that interacts with ibc-go’s callbacks middleware, specifically for ICS-20 transfer applications. Key Features:
  • Destination Callbacks: Execute contracts on packet receipt (onRecvPacket)
  • Source Callbacks: Handle acknowledgments (onAcknowledgePacket) and timeouts (onTimeoutPacket)
  • Atomic Execution: Contract calls happen atomically with token transfers

IBC Transfer Integration

The module works closely with the ICS20 transfer application to enable:
  • Cross-chain token transfers to EVM contracts
  • Automatic contract execution with received funds
  • Custom calldata propagation across chains
Smart contracts can initiate IBC transfers using the ICS20 Precompile, which provides the transfer function with memo field support for callbacks.
Address Format Limitation: Currently, IBC transfer receiver addresses must be in bech32 format (e.g., cosmos1...). While sender addresses are automatically converted from hex to bech32, receiver addresses must be provided in bech32 format. Full hex address support for receivers is planned for a future release.

Callback Types

Destination Callbacks (onRecvPacket)

Executed on the destination chain when a packet is received, allowing contracts to:
  • Receive cross-chain tokens
  • Execute custom logic with the received funds
  • Perform operations like DEX swaps or liquidity provision

Source Callbacks (onAcknowledgePacket & onTimeoutPacket)

Executed on the source chain when packet lifecycle completes, enabling contracts to:
  • Handle successful transfer acknowledgments
  • Recover funds from failed/timed out transfers
  • Implement retry logic for failed transfers

Implementation Details

Memo Format

EVM callbacks use the memo field in ICS-20 transfers with specific JSON structure: Destination Callback:
{
  "dest_callback": {
    "address": "0x...",
    "gas_limit": "1000000", 
    "calldata": "0x..."
  }
}
Source Callback:
{
  "src_callback": {
    "address": "0x...",
    "gas_limit": "1000000"
  }
}

Security Considerations

  • Isolated Addresses: Destination callbacks use ephemeral addresses to prevent confusion with local accounts
  • Sender Validation: Source callbacks validate that only the packet sender can set callbacks
  • Gas Limits: Callback execution is bounded by specified gas limits

External Resources