Skip to main content
Everything below uses fetch and WebSocket, so it runs unchanged in a browser or Node 18 and later.

Amounts

Work in base units as bigint. Parse the response with a reviver so large amounts do not pass through a double.
JSON.parse has already rounded a number above 2^53 by the time the reviver sees it. For tokens with very large supplies, parse with a bigint-aware library such as json-bigint instead.

Quote

Swap

Sign and send

The transaction is format v1. Decode it with a v1-aware library. @solana/web3.js 1.x throws on the version byte.
In a browser with a Wallet Standard wallet, pass the decoded transaction to the wallet’s sign method. The wallet signs and you send the bytes it returns. Confirm against swap.last_valid_block_height. Once the chain is past it, request a new swap rather than resending.

Streaming quote

Errors

See Errors for the full list.

Types