/v2/fungible/msgs 端点的 post_route_handler 参数,可以定义在路由转账或兑换完成后、于目标链上执行的操作。这些操作会与原始兑换或转账在同一笔交易中执行。
通过这个处理器,开发者可以构建全链与全代币工作流,让用户从 Cosmos 中的任意链或任意代币出发,在单笔交易中完成兑换、流动性质押、存款、购买 NFT 或其他任意操作。
该参数当前支持:
- 在目标链上调用 CosmWasm 合约
- 支持在 Stride 上进行流动性质押交互的
autopilot
背景信息
所有post_route 操作都必须满足以下特性:
- 无需许可: Skip Go 只能支持无需许可的操作,因为底层协议(例如 IBC hooks、IBC callbacks、packet-forward-middleware)会根据转账来源推导出用于调用合约的地址。Skip Go 会根据目标链接入的模块,支持
ibc-hooks和ibc-callbacks两种方式(两者互不兼容),并自动为各自生成合适的消息负载。这意味着,同一个用户如果从两条不同链发起,或以两种不同代币作为起点,最终调用目标合约或模块时使用的地址都会不同。只有在你能确定某个操作 1)始终从同一条链发起,且 2)始终通过同一路径到达目标链时,才可能可靠地为其配置权限。通常情况下,除非你是互操作性专家,否则我们不建议做这种假设。 - 单代币输入: 底层 IBC 转账协议(ICS-20)不支持在单条转账消息中传输超过 1 种代币 denom,因此我们一次只能向最终合约或模块发送 1 种代币 denom。这意味着
post_route_handler中的合约或模块不能要求同时接收多种代币 denom。例如,经典的 LP 操作通常要求用户同时提供资金池两侧的代币,这种场景就无法支持。
CosmWasm
要在目标链上调用 CosmWasm 合约,需要满足以下条件:- 目标链支持 CosmWasm,并且支持
ibc-hooks或ibc-callbacks之一。 - 路由中位于目标链之前的那条链支持 IBC memo,并且支持
packet-forward-middleware。
/v2/fungible/msgs 请求中将 wasm_msg 作为 post_route_handler 传入,其中包括:
contract_address:目标合约地址msg:传递给合约的消息 JSON 字符串
address_list 中的目标地址设置为该合约地址。
例如,下面这个请求表示将 USDC 从 Axelar 转账到 Neutron,并通过 post-route handler 在 Neutron 上使用 Astroport 池将 USDC 兑换为 Neutron:
address_list 中提供的最后一个地址是 Neutron 上的池合约地址,而不是用户地址。
该请求返回的消息会在 Neutron 上使用 ibc-hooks,从而在 IBC 转账的同时原子性地执行 CosmWasm 合约调用。
Autopilot
要在路由后操作中使用 Autopilot,需要满足以下条件:- 目标链支持
autopilot模块。目前这意味着目标链必须是stride-1。 - 路由中位于目标链之前的那条链支持 IBC memo,并且支持
packet-forward-middleware。
/v2/fungible/msgs 请求中将 autopilot_msg 作为 post_route_handler 传入,其中包括:
receiver:设置为你要代表其执行该操作的地址action:一个枚举值,用于指定你希望执行的操作- 可选值包括
LIQUID_STAKE(用于对资产进行流动性质押)或CLAIM(用于更新空投领取地址)。
- 可选值包括
有问题或反馈?欢迎帮助我们做得更好!加入我们的 Discord,并选择 “Skip Go Developer” 角色,与我们分享你的问题和反馈。
Use the
post_route_handler parameter of /v2/fungible/msgs endpoint to define actions that will be executed on the destination chain after a route transfer or swap is completed. These actions are executed within the same transaction as the original swap or transfer.
This handler allows developers to build omni-chain and omni-token workflows where users can swap, liquid stake, deposit, buy an NFT, or take any other action starting from any chain or any token in Cosmos — all in a single transaction.
This parameter currently supports:
- CosmWasm contract calls on the destination chain
autopilotsupport for liquid staking interactions on Stride
Background Info
Allpost_route actions must have the following characteristics:
- Permissionless: Skip Go can only support permissionless actions because the underlying protocols (e.g. IBC hooks, IBC callbacks, packet-forward-middleware) derive the addresses they use to call contracts based on the origin of the transfer. Skip Go supports both
ibc-hooksandibc-callbacksdepending on which module the destination chain has implemented (they are incompatible approaches), automatically generating the appropriate message payloads for each. This means one user originating on two different chains or starting with two different tokens will eventually call the final contract / module with different addresses. You can only reliably permission actions that you know will 1) always originate on the same chain and 2) always take the same path to the destination chain. In general, we recommend not making this assumption unless you are an interoperability expert - Single-token input: The underlying IBC transfer protocol (ICS-20) doesn’t support transfers of more than 1 token denom in a single transfer message, so we can only send 1 token denom to the final contract or module at a time. This means the contract or module in the
post_route_handlermust not require multiple token denoms sent to it simultaneously. For example, a classic LP action where the user must provide tokens in both sides of the pool simultaneously would not work.
CosmWasm
To call a CosmWasm contract on the destination chain, the following requirements must be satisfied:- The destination chain supports CosmWasm & either
ibc-hooksoribc-callbacks. - The chain in the route immediately before the destination chain supports IBC memos as well as
packet-forward-middleware.
wasm_msg as the post_route_handler in the /v2/fungible/msgs call with:
contract_address: The target contract addressmsg: JSON string of the message to pass to the contract
address_list to the address of the contract.
For example, this is a request for a transfer of USDC from Axelar to Neutron, with a post-route handler that swaps the USDC to Neutron using an Astroport pool on Neutron:
address_list is the address of the pool contract on Neutron, rather than a user address.
The message returned from this request uses ibc-hooks on Neutron to perform the CosmWasm contract call atomically with the IBC transfer.
Autopilot
To use Autopilot after route actions, the following requirements must be satisfied:- The destination chain supports the
autopilotmodule. Currently, this means the destination chain must bestride-1. - The chain in the route immediately before the destination chain supports IBC memos as well as
packet-forward-middleware.
autopilot_msg as the post_route_handler in the /v2/fungible/msgs call with:
receiver: Set to the address on behalf of which you’re performing the actionaction: An enum giving the action that you wish to execute- This may be one of
LIQUID_STAKE(for liquid staking an asset) orCLAIMfor updating airdrop claim addresses.
- This may be one of
Have questions or feedback? Help us get better!Join our Discord and select the “Skip Go Developer” role to share your questions and feedback.