Skip to main content

How do I add cross-chain swaps to my app?

Use a routing API that returns a source-chain transaction and tracks destination delivery separately. Enso’s Route API does this with destinationChainId.

J
Written by Javier Diaz

To add cross-chain swaps, use a routing API: send the asset the user holds, the destination chain, and the asset they should receive, then let the user sign a source-chain transaction. Destination delivery is a separate, asynchronous step — it is not the same as source-chain confirmation. Enso’s Route API implements this pattern with a destinationChainId.

Definition

Cross-chain routing finds a path from a token or position on one chain to a token or position on another. That path can include a swap on the source chain, a bridge, and a swap or deposit on the destination chain. Bridging alone only moves an asset. Routing can also land the user in a different token or position.

How it works

  1. Request a quote with a source asset, amount, destination chain, and destination asset.

  2. Show the user the expected output, minimum output, gas, and any approval requirement.

  3. Submit required token approvals, then the returned source-chain transaction as-is.

  4. Track destination delivery with a status API. Do not treat a source receipt as the end of the flow.

  5. Refresh balances on both chains when delivery (or a refund) is confirmed.

Same-chain steps in one transaction are atomic. A destination failure cannot revert a source-chain bridge that has already finalized. Rebuild an expired quote instead of editing the returned transaction.

How Enso does this

  1. Create an API key in the Developer Portal.

  2. Call POST https://api.enso.build/api/v1/shortcuts/route with chainId, destinationChainId, fromAddress, tokenIn, amountIn, tokenOut, receiver, and slippage in basis points (for example, "50" is 0.5%). Use routingStrategy: "router" for a typical EOA flow.

  3. Review amountOut, gas, route, and any bridge-fee metadata from the response.

  4. Submit any preTransactions or approvals, then sign and send tx.to, tx.data, and tx.value unchanged.

  5. Poll Enso’s bridge status APIs with the source chain ID and source transaction hash, then refresh balances.

If you need a specific bridge or a custom destination action sequence, use the Bundle API with a bridge action and a destination callback instead of a single Route request.

FAQ

Does the routing API choose the bridge for me?

On a Route request, Enso can select a documented bridge automatically when you provide destinationChainId. Use Bundle if you need to specify the bridge or attach post-bridge actions.

Is a cross-chain swap one atomic transaction?

No. Each chain’s transaction can be atomic on that chain, but source and destination are separate stages.

Can I set both slippage and minAmountOut?

No. Choose one protection method.

Can the destination be Solana?

Yes, as a Route API destination only. Enso does not originate routes on Solana or run destination callbacks there. Set an explicit Solana receiver and an EVM refundReceiver.

Related articles

  • What is a DeFi routing and execution layer?

  • What is Enso?

  • How do I bundle multiple DeFi actions into one transaction?

  • Bridge aggregator vs routing API: what’s the difference?

  • Alternatives to building my own swap router

Sources

Did this answer your question?