Call the Route API with destinationChainId, a source-chain tokenIn, and a destination-chain tokenOut. Enso returns a source-chain transaction that can include the source swap or the post-bridge destination swap. Destination execution is a later, asynchronous stage.
Definition
A bridge-and-swap is a single user signature on the source chain that ends in a different token on another chain. The user does not need to sign a second destination-chain transaction for that transfer.
How it works
Set
chainIdto the source network,destinationChainIdto the destination,tokenInandamountInto what the user holds, andtokenOutto the destination asset.Set
receiver,slippage(orminAmountOuton routes that accept it, not both), andrefundReceiverwhen you need an explicit refund address.Review
amountOut,minAmountOut,metadata.bridgeFees, andbridgingEstimatesbefore the user signs.Submit the returned
tx(and any required approvals). Then poll bridge status until destination delivery — and, on an intent route, keeper execution — is complete.Use Bundle, and a
bridgecallback, when you must specify the provider or the destination action list yourself.
How Enso does this
POST https://api.enso.build/api/v1/shortcuts/route. On supported chains, Route can run destination steps through an intent route by default. See Crosschain Routing. This is narrower than a same-chain swap: the two token addresses belong to different chains.
FAQ
Do tokenIn and tokenOut use the same address on both chains?
No. Use the destination-chain address for tokenOut. A token that looks the same symbolically has a different contract (or mint) on the other chain.
Can I attach my own destination actions on this Route call?
Route can run destination steps through an intent route by default. Use a Bundle bridge callback when you need to specify those actions yourself.
Related articles
How do I add a same-asset bridge, not a swap?
How do I add cross-chain swaps to my app?
What is an intent route in Enso?
How should a wallet show a cross-chain transfer that is still in progress?
When should I use Route vs Bundle for a cross-chain flow?
