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..."
}
'HttpResponse<String> response = Unirest.post("https://api.privy.io/v1/wallets/{wallet_id}/experimental/solana/advanced-swap")
.header("privy-app-id", "<privy-app-id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"input_token\": \"So11111111111111111111111111111111111111112\",\n \"output_token\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n \"caip2\": \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\",\n \"amount\": \"1000000000\",\n \"slippage_bps\": 50,\n \"platform_fee_bps\": 100,\n \"fee_recipient\": \"FeeAcct...\"\n}")
.asString();const options = {
method: 'POST',
headers: {
'privy-app-id': '<privy-app-id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
input_token: 'So11111111111111111111111111111111111111112',
output_token: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
caip2: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
amount: '1000000000',
slippage_bps: 50,
platform_fee_bps: 100,
fee_recipient: 'FeeAcct...'
})
};
fetch('https://api.privy.io/v1/wallets/{wallet_id}/experimental/solana/advanced-swap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.privy.io/v1/wallets/{wallet_id}/experimental/solana/advanced-swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'input_token' => 'So11111111111111111111111111111111111111112',
'output_token' => 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
'caip2' => 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
'amount' => '1000000000',
'slippage_bps' => 50,
'platform_fee_bps' => 100,
'fee_recipient' => 'FeeAcct...'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"privy-app-id: <privy-app-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.privy.io/v1/wallets/{wallet_id}/experimental/solana/advanced-swap"
payload := strings.NewReader("{\n \"input_token\": \"So11111111111111111111111111111111111111112\",\n \"output_token\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n \"caip2\": \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\",\n \"amount\": \"1000000000\",\n \"slippage_bps\": 50,\n \"platform_fee_bps\": 100,\n \"fee_recipient\": \"FeeAcct...\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("privy-app-id", "<privy-app-id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"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"
}
}Swaps
Advanced swap (Solana)
Execute a low-latency synchronous Solana token swap with an embedded wallet.
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..."
}
'HttpResponse<String> response = Unirest.post("https://api.privy.io/v1/wallets/{wallet_id}/experimental/solana/advanced-swap")
.header("privy-app-id", "<privy-app-id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"input_token\": \"So11111111111111111111111111111111111111112\",\n \"output_token\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n \"caip2\": \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\",\n \"amount\": \"1000000000\",\n \"slippage_bps\": 50,\n \"platform_fee_bps\": 100,\n \"fee_recipient\": \"FeeAcct...\"\n}")
.asString();const options = {
method: 'POST',
headers: {
'privy-app-id': '<privy-app-id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
input_token: 'So11111111111111111111111111111111111111112',
output_token: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
caip2: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
amount: '1000000000',
slippage_bps: 50,
platform_fee_bps: 100,
fee_recipient: 'FeeAcct...'
})
};
fetch('https://api.privy.io/v1/wallets/{wallet_id}/experimental/solana/advanced-swap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.privy.io/v1/wallets/{wallet_id}/experimental/solana/advanced-swap",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'input_token' => 'So11111111111111111111111111111111111111112',
'output_token' => 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
'caip2' => 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
'amount' => '1000000000',
'slippage_bps' => 50,
'platform_fee_bps' => 100,
'fee_recipient' => 'FeeAcct...'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"privy-app-id: <privy-app-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.privy.io/v1/wallets/{wallet_id}/experimental/solana/advanced-swap"
payload := strings.NewReader("{\n \"input_token\": \"So11111111111111111111111111111111111111112\",\n \"output_token\": \"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v\",\n \"caip2\": \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\",\n \"amount\": \"1000000000\",\n \"slippage_bps\": 50,\n \"platform_fee_bps\": 100,\n \"fee_recipient\": \"FeeAcct...\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("privy-app-id", "<privy-app-id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"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 tooptimistic_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_statusfield indicates whether the network acknowledged the transaction, not whether it confirmed onchain. Monitor the returnedtransaction_hashvia Solana RPC for final status. - The
signed_transactionfield 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
Headers
Body
application/json
Request body for initiating a synchronous Solana token swap through an embedded wallet.
Response
200 - application/json
Swap executed successfully.
Response from the synchronous Solana swap endpoint.
Was this page helpful?

