Docs

Solana Token Swaps via API

Firekeeper

What's New

GET /v1/solana/swap - Get Swap Quote

Get a quote for swapping Solana tokens without executing the transaction. See the expected output amount, USD values, and slippage before committing.

Example: Get quote to swap 0.1 SOL for USDC

curl -X GET "https://api.thirdweb.com/v1/solana/swap?address=YOUR_WALLET_ADDRESS&tokenIn=So11111111111111111111111111111111111111112&tokenOut=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amount=100000000&chainId=solana:mainnet" \
-H "x-secret-key: YOUR_SECRET_KEY"

Response:

{
"result": {
"inputMint": "So11111111111111111111111111111111111111112",
"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"inputAmount": "100000000",
"outputAmount": "15423156",
"inputUsdValue": 15.45,
"outputUsdValue": 15.42,
"slippageBps": 34,
"requestId": "019a5f00-fab2-747d-bba2-b77f993314a0"
}
}

POST /v1/solana/swap - Execute Swap

Execute a complete token swap with automatic signing, execution, and on-chain confirmation. The swap is confirmed on Solana within 30 seconds or returns a timeout error.

Example: Swap 0.1 SOL for USDC

curl -X POST "https://api.thirdweb.com/v1/solana/swap" \
-H "Content-Type: application/json" \
-H "x-secret-key: YOUR_SECRET_KEY" \
-d '{
"address": "YOUR_WALLET_ADDRESS",
"tokenIn": "So11111111111111111111111111111111111111112",
"tokenOut": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": "100000000",
"chainId": "solana:mainnet"
}'

Response:

{
"result": {
"signature": "5ttCNobho7nk5F1Hh4pU4d9T2o1yAFn3p1w8z8jk2jKd9KWCKN6dzyuT5xP1ny4wz9f5xCLjAF6Y9s9EoTW4aE1X",
"inputMint": "So11111111111111111111111111111111111111112",
"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"inputAmount": "100000000",
"outputAmount": "15423156",
"inputUsdValue": 15.45,
"outputUsdValue": 15.42,
"requestId": "019a5f00-fab2-747d-bba2-b77f993314a0"
}
}

View transaction: https://solscan.io/tx/5ttCNobho7nk5F1Hh4pU4d9T2o1yAFn3p1w8z8jk2jKd9KWCKN6dzyuT5xP1ny4wz9f5xCLjAF6Y9s9EoTW4aE1X

Key Features

Aggregated Liquidity - Best prices across multiple DEXs and liquidity sources
💰 USD Value Display - See real-time USD values for input and output amounts
Automatic Execution - No need to manually sign or submit transactions
🔒 Confirmed Results - Returns only after transaction is confirmed on-chain
🌐 Mainnet Only - Swaps available on Solana mainnet (solana:mainnet)
💸 Gasless Support - Qualifying swaps ($10+ with <0.01 SOL) may be gasless

Common Token Addresses

TokenMint Address
SOLSo11111111111111111111111111111111111111112
USDCEPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
USDTEs9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB

Request Parameters

ParameterTypeRequiredDescription
addressstringYesWallet address executing the swap
tokenInstringYesInput token mint address (token being sold)
tokenOutstringYesOutput token mint address (token being bought)
amountstringYesAmount in smallest unit (e.g., lamports for SOL)
chainIdstringYesMust be solana:mainnet

Response Fields

FieldTypeDescription
signaturestringTransaction signature (POST only)
inputMintstringInput token mint address
outputMintstringOutput token mint address
inputAmountstringAmount of input token swapped
outputAmountstringAmount of output token received
inputUsdValuenumberUSD value of input amount
outputUsdValuenumberUSD value of output amount
slippageBpsnumberSlippage tolerance in basis points
requestIdstringUnique request identifier

Amount Formatting

Amounts must be in the token's smallest unit (before decimals):

  • SOL (9 decimals): 1 SOL = 1000000000 lamports = "1000000000"
  • USDC (6 decimals): 1 USDC = 1000000 = "1000000"
  • 0.1 SOL: "100000000" (100 million lamports)
  • 10 USDC: "10000000" (10 million)

Error Handling

The API returns detailed error messages for common issues:

Insufficient Balance:

{
"error": {
"message": "Insufficient funds",
"statusCode": 400
}
}

Minimum Swap Amount ($10+ for gasless):

{
"error": {
"message": "Minimum $10 for gasless",
"statusCode": 400
}
}

Transaction Timeout:

{
"error": {
"message": "Swap transaction was not confirmed within timeout period",
"statusCode": 504
}
}

Ready to start swapping? Check out the full API documentation for more details.