Skip to main content
GET
Build Swap Transaction

Overview

The swap endpoint builds token swap transactions on Solana. You receive a serialized transaction that you sign and broadcast using your wallet.
This endpoint builds the transaction but does not execute it. You must sign and send the transaction yourself.

Supported Platforms

  • Pump.fun - Launch platform tokens
  • PumpSwap - Pump.fun liquidity pools
  • Orca - Concentrated liquidity
  • Meteora - Dynamic pools
  • Moonshot - New launches
  • Raydium - V4 AMM, CPMM, Launchpad
  • Jupiter - Aggregated routing

SDK Examples

Key Parameters

Amount Formats

The fromAmount parameter accepts:
  • Numeric: 1, 0.5 - Exact amount
  • Auto: "auto" - Entire wallet balance
  • Percentage: "50%", "25%" - Percentage of balance

Priority Fees

Partner / Referral Fees

Add your own partner or referral fees for monetization:

Examples

Swap with Auto Amount

Swap with Percentage

Swap with Custom Fee

Token Accounts and SOL Wrapping

The returned transaction already includes everything needed for the swap to land — you do not need to pre-create token accounts.
  • Associated Token Accounts (ATAs) are created automatically (idempotent) for the output token and any intermediate hop tokens when the payer wallet does not already have one. Rent (~0.00203 SOL per account) is paid by payer.
  • SOL wrapping/unwrapping is handled automatically: SOL is wrapped to wSOL when used as input, and any leftover wSOL is unwrapped back to native SOL when SOL is the output.

Response Structure

Solana Tracker Platform Fees

Standard fee: 0.5% of transaction value
  • Deducted from output
  • Shown in platformFee (lamports) and platformFeeUI (SOL)
  • Volume discounts available
Contact swap-api@solanatracker.io for volume pricing

Common Errors

Next Steps

Rate Endpoint

Get quotes before swapping

JavaScript SDK

Install the SDK

Query Parameters

from
string
required

The base token address

Example:

"So11111111111111111111111111111111111111112"

to
string
required

The quote token address

Example:

"4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R"

fromAmount
required

The amount of the base token to swap. Accepts numeric value, 'auto' for full wallet balance, or percentage like '50%'

Example:

1

slippage
required

Maximum acceptable slippage percentage or 'auto' for dynamic slippage (Beta)

Required range: 0 <= x <= 100
Example:

10

payer
string
required

Public key of the wallet sending the transaction

Example:

"arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y"

priorityFee

Amount in SOL to increase transaction priority or 'auto'

Example:

0.000005

priorityFeeLevel
enum<string>
default:medium

Priority level when priorityFee is set to 'auto'

Available options:
min,
low,
medium,
high,
veryHigh,
unsafeMax
txVersion
enum<string>
default:v0

Transaction version

Available options:
v0,
legacy
fee
string

Custom fee for your users in format 'WALLET_ADDRESS:PERCENTAGE'

Pattern: ^[a-zA-Z0-9]+:[0-9]+(\.[0-9]+)?$
Example:

"arsc4jbDnzaqcCLByyGo7fg7S2SmcFsWUzQuDtLZh2y:0.1"

customTip
string

Custom tip for Jito or similar services in format 'WALLET_ADDRESS:SOL_AMOUNT'

Pattern: ^[a-zA-Z0-9]+:[0-9]+(\.[0-9]+)?$
feeType
enum<string>
default:add

Fee application type. 'deduct' option is only used when the from address is SOL

Available options:
add,
deduct
onlyDirectRoutes
boolean
default:false

Disable multi-hop swaps

Response

Successful swap transaction

txn
string

Base64 encoded transaction

Example:

"BASE64_TX"

rate
object
timeTaken
number

Time taken for the operation in seconds

Example:

0.016

type
enum<string>

Transaction type

Available options:
v0,
legacy
Example:

"legacy"