Was this helpful?
Build on Tempo
Use this guide when you want to leave Zone A with pathUSD and arrive in with in one routed flow. The trade briefly touches the public chain, so the confirmation happens in stages rather than as a single balance update.
Zone BbetaUSDThe route uses swapAndDepositRouter on the public chain: withdraw from Zone A, swap on the Stablecoin DEX, then deposit the output token into Zone B.
By the end of this guide you will have swapped 25 pathUSD from Zone A into betaUSD on Zone B and confirmed the routed deposit.
pathUSD from Zone A.Zone B through ZonePortal.Zone B so you can confirm the final betaUSD balance.This snippet assumes you already have a signed-in rootClient on the public chain plus zoneAClient, and the shared token, router, and portal constants used throughout the zone guides.
It shows the core routed swap submission path; use the demo above when you want to watch the output deposit settle into Zone B.
import { encodeAbiParameters, parseUnits } from 'viem'
import { Actions } from 'viem/tempo'
const swapAmount = parseUnits('25', 6)
await zoneAClient.zone.signAuthorizationToken()
const routedWithdrawalFee = await zoneAClient.zone.getWithdrawalFee
This guide's swap flow is asynchronous because the trade temporarily leaves the zone.
The source token is withdrawn through ZoneOutbox, transferred to SwapAndDepositRouter on Tempo, optionally swapped on the Stablecoin DEX, and then deposited back through a ZonePortal as the output token. That routed deposit pays the normal portal deposit fee, so the amount that arrives on the zone is the post-fee output.