Key Differences from Standard IBC Transfer
1. Enhanced Transfer Response
Instead of an empty response, Neutron provides tracking information:2. Contract Detection and Callbacks
The Transfer module automatically detects smart contract senders usingHasContractInfo()
and provides Sudo callbacks for transfer results.
Callback messages are prepared using the Contract Manager module’s PrepareSudoCallbackMessage()
function.
3. Fee Integration
4. Contract-Specific Validation
The Transfer module includes conditional validation:- For contracts: Fee validation is required
- For non-contracts: Fee validation is bypassed
5. Automatic Fee Operations
For contract senders, the module automatically:Module Implementation
Wrapper Architecture
The module implements a wrapper pattern around the standard IBC Transfer module:Method Overrides
Key methods are overridden to add contract functionality:- OnAcknowledgementPacket(): Adds callback processing after standard IBC handling
- OnTimeoutPacket(): Adds callback processing after standard IBC handling
- Transfer(): Adds contract detection, fee validation/locking, and enhanced response
Standard IBC Delegation
All standard IBC Transfer functionality is delegated to the underlying implementation:Error Handling
Sudo Call Error Handling
The Transfer module’s callback error handling:Fee Processing Independence
Fee operations occur independently of callback success:- Fee locking happens before packet transmission
- Fee distribution occurs regardless of callback outcomes
- IBC processing continues even if contracts fail to handle callbacks
Integration Dependencies
The Transfer module relies on external modules for specific functionality:Contract Manager Module
- PrepareSudoCallbackMessage(): Determines callback message format and structure
- Request ID handling: Manages correlation between transfers and callbacks
- Sudo message specifications: Defines contract interface requirements
Fee Refunder Module
- Fee structure: Defines
neutron.feerefunder.Fee
type and validation - Fee operations: Implements
LockFees()
,DistributeAcknowledgementFee()
,DistributeTimeoutFee()
- Balance requirements: Manages fee payment and distribution logic
Key Concepts
Transfer Flow for Contracts
- Contract Detection: Module checks
HasContractInfo(ctx, senderAddress)
- Fee Validation: Calls
msg.Fee.Validate()
for contracts only - Fee Locking: Uses
FeeKeeper.LockFees()
before packet transmission - Standard IBC Processing: Delegates to underlying IBC Transfer module
- Enhanced Response: Returns
sequence_id
andchannel
information - Callback Preparation: Uses Contract Manager’s
PrepareSudoCallbackMessage()
- Sudo Callback: Calls
sudoKeeper.Sudo()
with prepared message - Fee Distribution: Distributes fees to relayers regardless of callback success
Non-Contract Processing
For non-contract senders:- Fee validation is skipped
- Fee locking is bypassed
- No callbacks are sent
- Standard IBC processing applies
- Standard (empty) response is returned