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).

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 July 22, 2026