Learn how to integrate the callbacks middleware with IBC applications. The following document is intended for developers building on top of the Cosmos SDK and only applies for Cosmos SDK chains. The callbacks middleware is a minimal and stateless implementation of the IBC middleware interface. It does not have a keeper, nor does it store any state. It simply routes IBC middleware messages to the appropriate callback function, which is implemented by the secondary application. Therefore, it doesn’t need to be registered as a module, nor does it need to be added to the module manager. It only needs to be added to the IBC application stack.Documentation Index
Fetch the complete documentation index at: https://docs.cosmos.network/llms.txt
Use this file to discover all available pages before exploring further.
Pre-requisite Readings
The callbacks middleware, as the name suggests, plays the role of an IBC middleware and as such must be configured by chain developers to route and handle IBC messages correctly. For Cosmos SDK chains this setup is done via theapp/app.go file, where modules are constructed and configured in order to bootstrap the blockchain application.
Configuring an application stack with the callbacks middleware
As mentioned in IBC middleware development an application stack may be composed of many or no middlewares that nest a base application. These layers form the complete set of application logic that enable developers to build composable and flexible IBC application stacks. For example, an application stack may just be a single base application liketransfer, however, the same application stack composed with packet-forward-middleware and callbacks will nest the transfer base application twice by wrapping it with the callbacks module and then packet forward middleware.
The callbacks middleware also requires a secondary application that will receive the callbacks to implement the ContractKeeper. The wasmd contract keeper has been implemented here and is referenced as the WasmKeeper.
Transfer
See below for an example of how to create an application stack usingtransfer, packet-forward-middleware, and callbacks. Feel free to omit the packet-forward-middleware if you do not want to use it.
The following transferStack is configured in app/app.go and added to the IBC Router.
The in-line comments describe the execution flow of packets between the application stack and IBC core.