Introducing a new way to review your PRs.

Read the announcement

lfdt-ibc / ibc-go

Inter-Blockchain Communication Protocol (IBC) implementation in Golang.

View on GitHub

20 documents · Updated Nov 13, 2026

docs / token-transfer

IBC fungible token transfer

IBC fungible token transfer moves a fungible token between accounts on two connected chains while preserving the token's origin. The transfer application uses denomination traces to identify vouchers, locks or burns the sending balance, and then releases or creates the matching balance on the other chain. It runs through the IBC channel layer and can sit below packet-forwarding and rate-limit middleware. See IBC application modules for the application-layer map, and interchain accounts and general message passing for other IBC application patterns.

Transfer model

Denomination tracing

A denomination trace records the port and channel hops that a token took before it reached the current chain. The full path is the trace followed by the base denomination. A non-native path is represented on chain by ibc/<hash>, while the transfer module keeps the trace so it can recover the path when a later transfer uses that token.

The first trace hop identifies whether the token is returning through the channel that sent it. This makes the trace a movement record, not only a display name:

MovementTrace action at the destinationBalance action
Token moves to a new chainAdd the destination port and channel to the front of the traceCreate a voucher
Token returns to its previous source chainRemove the matching first hopRelease the escrowed token

For example, a native token moving A → B → C is represented as transfer/<B-C channel>/transfer/<A-B channel>/base in path form. A return from C to B removes the first matching hop. The hash of the complete path gives the local IBC denomination, so different paths remain different assets even when they share a base denomination.

References: modules/…/denom.go• L25-99 modules/…/hop.go• L13-34 modules/…/relay.go• L76-104

Source and sink zones

A source zone is the chain that sends a token forward in its trace. A sink zone is the chain that sends a voucher back toward the chain that created the original token. This distinction selects the accounting action on both sides of a packet.

The sender puts the denomination path that exists on its own chain into the packet. The receiver then checks the source hop against the packet's source port and channel. A match means the packet carries a token that this chain originally escrowed. No match means the receiver must create a new voucher and add its destination hop.

References: modules/…/relay.go• L80-104 modules/…/relay.go• L149-202

Escrow and voucher accounting

Escrow is the lock that backs native tokens while they are represented as vouchers on another chain. Each source port and channel has a deterministic escrow address. The module also tracks the total escrowed amount for each denomination so operators and queries can compare the backing balance with the module's recorded amount.

The accounting rules are:

  • A forward send moves the sender's coin to the channel escrow address.
  • A return send burns the sender's voucher.
  • A source-side receive mints the voucher and sends it to the receiver.
  • A sink-side receive sends the matching coin from escrow to the receiver.
  • A failed acknowledgement or timeout reverses the send-side action.

When a voucher is first received, the module stores its trace and adds bank metadata. This gives the local bank module both a unique denomination and a useful display description without changing the token's trace identity.

References: modules/…/relay.go• L80-104 modules/…/relay.go• L156-202 modules/…/relay.go• L245-329 modules/…/keeper.go• L195-260

Transfer lifecycle

Transfer request

The transfer request accepts a source port and channel, a positive coin, sender and receiver addresses, timeout data, and an optional memo. The module validates the coin and packet fields before it changes balances. A special maximum-value amount can mean “send the spendable balance” for the selected denomination.

For an existing IBC v1 channel, the request uses the v1 packet path. If the channel is absent or the request uses channel aliasing, it sends through the IBC v2 packet path. Both paths use the same source-versus-sink accounting rules. The packet can use JSON, protobuf, or Solidity ABI encoding through the supported packet-data boundary.

This diagram shows how a request becomes a packet and how the packet result controls the final balance change.

flowchart LR
    R[Transfer request] --> V[Validate coin and packet]
    V --> D[Build traced token data]
    D --> S{IBC v1 channel path?}
    S -->|Yes| P1[Send through v1 channel]
    S -->|No or aliased| P2[Send through v2 router]
    P1 --> A[Remote receive]
    P2 --> A
    A -->|Success| C[Keep escrow or burned voucher state]
    A -->|Error or timeout| F[Refund sender]

References: modules/…/msg_server.go• L24-80 modules/…/msg_server.go• L83-141 modules/…/msgs.go• L110-182 modules/…/packet.go• L195-210

Packet receive

The receive callback decodes and validates the packet, checks that receiving is enabled, validates the destination address, and applies the source or sink accounting rule. A successful receive returns a success acknowledgement. A validation or balance error returns a failure acknowledgement instead of crediting the receiver.

The packet memo travels with the transfer. The transfer packet type exposes memo values as custom packet data, which lets middleware inspect agreed keys such as callback instructions without changing the core token accounting. See callbacks and rate limiting for middleware behavior.

IBC v1 returns a structured success or error acknowledgement. IBC v2 also accepts its transport-level error sentinel, but it rejects a custom error acknowledgement before it reaches the shared refund logic.

References: modules/…/ibc_module.go• L166-216 modules/…/ibc_module.go• L88-149 modules/…/ibc_module.go• L168-200 modules/…/packet.go• L59-78 modules/…/packet.go• L103-123

Acknowledgement and timeout refunds

The sender does not reverse a successful transfer after the remote chain acknowledges it. An error acknowledgement or a packet timeout instead calls the refund path. The refund path unescrows a coin when the send locked source funds, or mints the burned voucher when the send destroyed a returning voucher.

The refund uses the original source port and channel to find the escrow address. This keeps the refund tied to the same channel-specific backing account that held the send-side funds.

References: modules/…/ibc_module.go• L219-270 modules/…/ibc_module.go• L152-200 modules/…/relay.go• L208-294

Governance controls

Transfer parameters

The transfer module has two chain-wide switches. send_enabled controls new outgoing transfers. receive_enabled controls incoming packet processing. Both switches are enabled by default. The bank module's per-denomination send setting can provide a narrower block when a chain must stop one asset without stopping all transfers.

Only the configured module authority can update these parameters. The transfer module checks the authority before it stores the new values, and it exposes the current values through its query service.

References: proto/…/transfer.proto• L9-20 modules/…/params.go• L5-23 modules/…/msg_server.go• L144-153 modules/…/grpc_query.go• L81-89

Address restrictions

The transfer module defers blocked-address policy to the bank keeper for both senders and receivers. The transfer module account remains allowed so that mint, burn, escrow, and release operations can complete. A blocked user address therefore fails before the packet changes token state.

References: modules/…/keeper.go• L299-308 modules/…/relay.go• L59-65 modules/…/relay.go• L132-139

Chain integration

Channel contract

Transfer channels are unordered and use the port bound to the transfer module. Channel opening accepts a supported application version and limits the channel sequence because the channel identifier contributes to escrow address safety. User-initiated channel close is rejected. The channel remains part of the token's trace and backing model.

References: modules/…/ibc_module.go• L43-72 modules/…/ibc_module.go• L75-155

IBC v1 and IBC v2 interfaces

The transfer application presents one token-transfer model through two IBC callback interfaces. IBC v1 uses negotiated channel identifiers and packet data with the v1 application version. IBC v2 uses payloads routed by the v2 IBC router and supports JSON, protobuf, or Solidity ABI packet encodings where the packet type allows them.

IBC v2 adds boundary checks because its packet path does not use the v1 channel handshake in the same way. Both payload ports must be the transfer port. Both channel values must be valid client identifiers. The packet signer must match the embedded sender. The base denomination cannot contain a slash.

References: modules/…/packet.go• L38-42 modules/…/packet.go• L195-289 modules/…/ibc_module.go• L38-85

Middleware stack

The chain wires transfer below packet-forwarding and rate-limit middleware. Outgoing packets move from transfer toward core IBC through those layers. Incoming packets move from core IBC down through rate limiting and packet forwarding before they reach transfer. This ordering lets middleware inspect or constrain a transfer without replacing the transfer module's escrow and voucher rules.

See packet forwarding for forwarded transfer behavior and callbacks and rate limiting for middleware controls.

sequenceDiagram
    participant T as Transfer
    participant P as Packet forwarding
    participant L as Rate limiting
    participant C as Core IBC channel

    T->>P: Send packet
    P->>L: Forward or pass packet
    L->>C: Send packet
    C-->>L: Receive, acknowledgement, or timeout
    L-->>P: Packet callback
    P-->>T: Transfer callback

References: simapp/app.go• L383-450 modules/…/keeper.go• L70-79 modules/…/ibc_module.go• L273-294

Module state and services

The chain module binds the transfer port at genesis and restores denomination traces, parameters, and total escrowed amounts from genesis state. Its application module registers message and query services, supports genesis import and export, and carries the module through consensus-version migrations.

The main query surface covers current parameters, stored denomination traces, trace hashes, channel escrow addresses, and total escrow for a denomination. These views help an operator connect a local ibc/<hash> balance to its origin and to the funds that back it. The module also exposes command-line actions for transfer transactions and these query views.

The current module state includes the port, denomination records, governance parameters, and total escrow values. Genesis validation rejects invalid ports, duplicate denomination hashes, and duplicate escrow denominations before state is restored.

References: modules/…/genesis.go• L11-37 modules/…/genesis.go• L21-41 modules/…/module.go• L113-145 modules/…/grpc_query.go• L27-162 proto/…/query.proto• L16-124

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to trace parsing, path hashing, or the ibc/<hash> form must stay aligned with stored reverse traces, bank metadata, packet validation, and query inputs.
  • Changes to source-versus-sink detection must update send, receive, acknowledgement, and timeout paths together. All four paths must use the same port and channel when deriving escrow state.
  • Changes to packet version or encoding must update both v1 and v2 marshal and unmarshal boundaries. They must also preserve the v2 signer and denomination checks.
  • Changes to middleware order must preserve the transfer stack contract for both outgoing sends and incoming callbacks.
  • Changes to module authority, bank permissions, or the transfer module account must preserve parameter updates and mint, burn, escrow, and refund operations.
  • Changes to denomination or escrow state must preserve genesis validation, export, and migration behavior so a chain restart does not lose token identity or backing totals.

Important failure modes

TriggerConsequenceGuard
send_enabled or receive_enabled is falseThe outgoing request or incoming packet is rejected before token movementAuthority-controlled transfer parameters and parameter query
A packet contains an unknown ibc/<hash> or invalid traceThe chain cannot resolve the token's origin and the transfer failsTrace validation and the stored hash-to-denomination lookup
A sink packet points to the wrong source port or channelUnescrow cannot use the correct backing account and the receive or refund failsChannel-specific trace matching and deterministic escrow addresses
A transfer channel is ordered, uses another port, or exceeds the channel limitChannel opening failsTransfer channel validation
A v2 packet uses another port, invalid client identifiers, an unsigned sender, or a slash in its base denominationThe v2 packet is rejected before send or receive accountingv2 payload and signer validation
A v2 acknowledgement uses an unsupported custom error formThe acknowledgement callback rejects it instead of applying shared transfer handlingv2 acknowledgement validation
A failed packet needs an unescrow but the escrow balance is too lowThe refund or receive action fails rather than creating unsupported native supplyEscrow totals and bank balance checks

Key files

FileWhy to read it
modules/…/relay.goCore source, sink, mint, burn, escrow, unescrow, acknowledgement, and timeout rules
modules/…/denom.go and modules/…/hop.goDenomination path, trace hop, hash, and local IBC denomination model
modules/…/msg_server.goUser transfer entry point and the choice between v1 and v2 packet paths
modules/…/ibc_module.goIBC v1 channel and packet callback contract
modules/…/ibc_module.goIBC v2 payload checks and packet callback contract
modules/…/packet.goPacket fields, validation, memo access, and supported encodings
modules/…/params.go and proto/…/transfer.protoDefault and governed transfer switches
modules/…/genesis.go and proto/…/query.protoState restoration, export, and operator query surface
modules/…/module.goApplication services, genesis hooks, and consensus-version migrations
simapp/app.goKeeper construction, router registration, and transfer middleware order