Skip to main content
POST
/
v1
/
wallets
/
{wallet_id}
/
experimental
/
solana
/
advanced-swap
Advanced swap
curl --request POST \
  --url https://api.privy.io/v1/wallets/{wallet_id}/experimental/solana/advanced-swap \
  --header 'Authorization: Basic <encoded-value>' \
  --header 'Content-Type: application/json' \
  --header 'privy-app-id: <privy-app-id>' \
  --data '
{
  "input_token": "So11111111111111111111111111111111111111112",
  "output_token": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "caip2": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
  "amount": "1000000000",
  "slippage_bps": 50,
  "platform_fee_bps": 100,
  "fee_recipient": "FeeAcct..."
}
'
{
  "transaction_hash": "5K4f...base58sig",
  "submission_status": "accepted",
  "signed_transaction": "AQAAAA...base64...",
  "provider": "dflow",
  "input_token": "So11111111111111111111111111111111111111112",
  "output_token": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "in_amount": "1000000000",
  "out_amount": "173500000",
  "min_out_amount": "172632500",
  "slippage_bps": 50,
  "platform_fee": {
    "amount": "1735000",
    "bps": 100,
    "token": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
  }
}
This is a Privy Labs API. It is subject to change as Privy iterates on the design with partners. Privy provides at least three months of notice before removing a documented Labs API.

Overview

The advanced swap endpoint performs a synchronous Solana token swap in a single request: Privy fetches a quote, signs the transaction via the enclave, and submits it to the network. Wallet data preparation is parallelized with the swap quote fetching to minimize latency. Unlike the standard swap endpoint, this endpoint returns the signed transaction directly rather than creating an asynchronous wallet action. To learn more about the design of this endpoint, see our blog post on reducing trading latency.

Prerequisites

  • The wallet must be a Solana embedded wallet
  • Your app must be approved for access to this Labs endpoint

Considerations

This endpoint behaves similarly to optimistic_broadcast on the standard Solana sign-and-send endpoint:
  • The response is returned as soon as the transaction is signed and submitted, it does not wait for onchain confirmation.
  • The submission_status field indicates whether the network acknowledged the transaction, not whether it confirmed onchain. Monitor the returned transaction_hash via Solana RPC for final status.
  • The signed_transaction field contains the fully signed transaction (base64-encoded), which can be rebroadcast to any Solana RPC endpoint for redundancy or improved landing rates.
  • Your app is responsible for checking transaction validity and rebroadcasting if needed.

Authorizations

Authorization
string
header
required

Basic Auth header with your app ID as the username and your app secret as the password.

Headers

privy-app-id
string
required

ID of your Privy app.

privy-authorization-signature
string

Request authorization signature. If multiple signatures are required, they should be comma separated.

Path Parameters

wallet_id
string
required

ID of the wallet.

Body

application/json

Request body for initiating a synchronous Solana token swap through an embedded wallet.

input_token
string
required

Input token address (base58 mint address).

output_token
string
required

Output token address (base58 mint address).

amount
string
required

Amount in the smallest unit of the input token (e.g. lamports for SOL).

caip2
string

CAIP-2 chain identifier. Defaults to Solana mainnet.

slippage_bps
default:auto

Max slippage tolerance in basis points (0-10000), or "auto" for provider-determined. Defaults to "auto".

Required range: 0 <= x <= 10000
dry_run
boolean

When true, skip transaction submission (quote + sign only). The signed transaction is still returned.

platform_fee_bps
integer

Platform fee in basis points, taken from the output token. Requires fee_recipient when > 0.

Required range: 0 <= x <= 10000
fee_recipient
string

Token account (base58) to receive the platform fee. Must exist on-chain for the output token.

Response

200 - application/json

Swap executed successfully.

Response from the synchronous Solana swap endpoint.

transaction_hash
string
required

Solana transaction signature (base58).

submission_status
enum<string>
required

"accepted" if the network has acknowledged the transaction, "rejected" if the network refused it, "skipped" if dry_run was set. Not an onchain confirmation.

Available options:
accepted,
rejected,
skipped
signed_transaction
string
required

Fully signed transaction (base64). Callers can re-submit to any Solana RPC for redundancy.

provider
string
required

Which aggregator fulfilled the swap (e.g. "dflow").

input_token
string
required

Input token address (base58).

output_token
string
required

Output token address (base58).

in_amount
string
required

Input amount consumed (smallest unit).

out_amount
string
required

Expected output amount before slippage (smallest unit).

min_out_amount
string
required

Minimum output amount guaranteed by slippage tolerance (smallest unit).

slippage_bps
integer
required

Slippage applied in basis points. Reflects the resolved value if "auto" was requested.

platform_fee
AdvancedSwapPlatformFee · object

Platform fee details, present when a fee was applied.