pending status and can be polled for confirmation.
View the full API reference for the swap endpoint.
Usage
Use the
swap method from the useSwap hook to swap tokens from a user’s embedded wallet.useSwap is supported starting in @privy-io/react-auth@3.51.4.React and React Native parameters
In both SDKs,swap(walletId, params) accepts the embedded wallet’s ID, not its blockchain address,
and an object with the body fields below. Replace the example token placeholders with contracts deployed on Tempo.
base_amount uses the token’s smallest unit, not a human-readable decimal amount.
The hook signs the request with the user’s signer. Never include app secrets or authorization private keys in client-side code.
It returns a Promise for a SwapActionResponse with status: 'pending', without waiting for onchain confirmation.
Use action.id with getAction from useWalletActions to track completion.
For a cross-chain swap from Tempo to Solana, use the following destination in either SDK example:
destination.destination_address is required when swapping between EVM and Solana. See supported routes.
Body
The SDKparams object and REST request body accept the following fields:
Amount in base units (e.g., wei for ETH, lamports for SOL, or the token’s smallest unit).
Whether
base_amount refers to the input or output token. Defaults to exact_input.Maximum slippage tolerance in basis points (e.g.,
50 for 0.5%). If omitted, auto-slippage is
used.Response
The address receiving output tokens on the destination chain. Present when
destination.destination_address was specified. Cross-chain swaps only.Estimated fee breakdown at the time of execution. Each item has a
type (relayer, or
developer) and an amount in USD. Items of type developer include a recipient address.
Present for cross-chain swaps only.Estimated gas cost at the time of execution. Contains
base_amount, amount, and gas_asset
fields. Present for cross-chain swaps only.Actual fees paid. Populated after the swap is confirmed. Same structure as
estimated_fees.
Present for cross-chain swaps only.
