Skip to main content

Prerequisites

Before this page: a connected or embedded wallet (see Connecting external wallets).

What you’ll build

A swap flow has four steps:
  1. Quote — ask for a route between two tokens.
  2. Show the estimated amount received and gas cost.
  3. Execute — sign and submit from the user’s wallet.
  4. Track — poll until the swap is done.
Amounts are always in the token’s smallest unit (for example, 1000000 for 1 USDC with 6 decimals).

Choosing tokens

Build your token pickers from getSwapChains and getSwapTokens instead of hardcoding addresses. getSwapChains lists the networks that support swaps, and getSwapTokens lists the tokens on one network or searches them by name, symbol, or address. Each token includes the address and decimals you need for the quote. For the token the user swaps from, show only the listed tokens the wallet holds, using its token balances. This keeps unsupported and spam tokens out of the picker. A listed token can be swapped on its network, but a specific pair is not guaranteed, so the quote remains the final check.

Quoting a swap

getSwapQuote takes a from and to side. Set from.amount to quote by input (or to.amount to quote by desired output — they’re mutually exclusive). The response includes the signingPayload you’ll execute and the estimated to.amount.

Executing the swap

Pass the quote’s signingPayload to executeSwapTransaction. ERC-20 swaps may need a separate approval first — onStepChange tells you which step is running so you can update the UI.

Tracking status

A swap can take time to settle — especially across chains. Poll getSwapStatus with the transaction hash until the status is DONE or FAILED.
Re-check on an interval and resolve only once the swap reaches a terminal status.

Handling errors

See also

Last modified on November 27, 2026