> ## Documentation Index
> Fetch the complete documentation index at: https://cosmos-docs-sync-security-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# IBC

> Inter-Blockchain Communication protocol implementation with EVM callbacks

The `x/ibc` module from [cosmos/evm](https://github.com/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](https://github.com/cosmos/ibc-go/blob/main/modules/apps/callbacks/README.md), 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

<Info>
  Smart contracts can initiate IBC transfers using the [ICS20 Precompile](/evm/latest/documentation/smart-contracts/precompiles/ics20), which provides the `transfer` function with memo field support for callbacks.
</Info>

<Warning>
  **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.
</Warning>

## 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:**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "dest_callback": {
    "address": "0x...",
    "gas_limit": "1000000",
    "calldata": "0x..."
  }
}
```

**Source Callback:**

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "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

## Related Documentation

* [IBC Overview](/evm/latest/documentation/concepts/ibc) - IBC concepts and fundamentals
* [ICS20 Precompile](/evm/latest/documentation/smart-contracts/precompiles/ics20) - Cross-chain token transfers
* [Callbacks Interface](/evm/latest/documentation/smart-contracts/precompiles/callbacks) - Smart contract callback interface

## External Resources

* [IBC Protocol Specification](/ibc/latest/intro)
* [IBC-Go Callbacks Middleware](https://github.com/cosmos/ibc-go/blob/main/modules/apps/callbacks/README.md)
* [ICS-20 Token Transfer](https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer)
