Examples
Bridging
Get calldata for bridging tokens across chains.
Enso’s bundle
API provides the bridge
action to facilitate cross-chain token transfers using Stargate.
You can construct the bundle in the following way:
- pre-bridge actions that prepare the tokens for bridging, such as swapping or charging fees
- a
bridge
action that transfers the tokens to the destination chain - use
bridge
action’scallback
- an array of post-bridge actions that execute on the destination chain. Callbacks can reference outputs from previous actions using theuseOutputOfCallAt
- When using callbacks, the callback bundle must start with a balance action to check the bridged token balance on the destination chain.
- To apply slippage constraints to the bridged tokens, you must use the
slippage
action in the callback bundle, referencing the outputs of the split viauseOutputOfCallAt
.
Example
This example demonstrates how to use the bridge
action in a bundle to transfer tokens from Ethereum Mainnet to Base using Stargate. It includes a series of actions that:
- swap USDC from mainnet to ETH using Enso routing for optimal path
- charge a fee in ETH
- bridge the ETH to Base using Stargate
- check the bridged ETH balance on Base
- split the ETH into two tokens
- apply slippage constraints to the split tokens, referencing the outputs of the split via
useOutputOfCallAt
- deposit the split tokens into Uniswap V4 pools on Base
Next Steps:
Updated