Integrate IBC to your application and send data packets to other chains

  • Add required modules to the module.BasicManager
  • Define additional Keeper fields for the new modules on the App type
  • Add the module’s StoreKeys and initialize their Keepers
  • Set up corresponding routers and routes for the ibc module
  • Add the modules to the module Manager
  • Add modules to Begin/EndBlockers and InitGenesis
  • Update the module SimulationManager to enable simulations

func NewApp(…args) *App {
// define codecs and baseapp

// add capability keeper and ScopeToModule for ibc module
app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey])

// grant capabilities for the ibc and ibc-transfer modules
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibcexported.ModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)

// … other modules keepers

// Create IBC Keeper
app.IBCKeeper = ibckeeper.NewKeeper(
appCodec, keys[ibcexported.StoreKey], app.GetSubspace(ibcexported.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper,

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
app.AccountKeeper, app.BankKeeper, scopedTransferKeeper,
transferModule := transfer.NewAppModule(app.TransferKeeper)

// … continues

func NewApp(…args) *App {
// … continuation from above

// add staking and ibc modules to BeginBlockers
// other modules …
stakingtypes.ModuleName, ibcexported.ModuleName,

// …

// NOTE: Capability module must occur first so that it can initialize any capabilities
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
// other modules …
ibcexported.ModuleName, ibctransfertypes.ModuleName,

// … continues