Skip to main content
Prefer HTTP? Same flow over REST: Swap API. Prefer Solana-first? Solana quickstart.
Getting this code running and having a submitted swap settle are two different things — see the last step, Poll until settled.
This submits a real transaction on mainnet and spends real funds. Use a throwaway wallet holding only what you intend to swap, and keep its key in an environment variable — never in source.
1

Install

Two packages: @sodax/sdk builds and tracks the intent, @sodax/wallet-sdk-core signs it. Both are needed — the SDK never holds a key.Every snippet below is one ESM module, top to bottom.
2

Initialize

In a browser you pass a walletClient / publicClient pair instead of a key. See @sodax/wallet-sdk-core.
3

Quote

A quote costs nothing and signs nothing — a good place to confirm your setup works before spending anything.
4

Execute

Always branch on result.ok / error.code — never try/catch on the message string.
This example swaps native gas tokens, which need no allowance. swap() does not approve for you — with an ERC-20 input, call sodax.swaps.isAllowanceValid and then sodax.swaps.approve first, or the swap fails. Full sequence: Make a swap (SDK).
5

Poll until settled

Settlement is not instant, and it is not on a fixed schedule. This loop gives up after 5 minutes (60 polls × 5s) — tune that budget to your needs. How long a fill actually takes depends on solver and relay conditions rather than on your code, so treat SOLVED as the only success signal and don’t design around a fixed duration.Watch destination fills via fill_tx_hash, or track cross-network message delivery on SODAX Scan.

Next

Full swap walkthrough

Wallet setup, errors, limit orders, and status codes.

HTTP Swap API

Quote, build intent, submit-tx, status — any language.

AI coding agents

Install @sodax/skills so agents write v2-correct code.

Builders MCP

Live chains, tokens, quotes, and SDK docs for agents.