Skip to main content

Build Transaction

POST /api/v1/swap builds a complete unsigned Solana transaction for a token swap. Sign it with the user’s wallet and submit to the network.

Request

userWallet
string
required
User’s wallet address (base58). This wallet signs and pays for the transaction.
inputMint
string
required
Input token mint address.
outputMint
string
required
Output token mint address.
amount
string
required
Amount in smallest token units.
swapMode
string
required
ExactIn or ExactOut.
slippageBps
integer
default:"50"
Slippage tolerance in basis points. Default: 50 (0.5%).
skipSimulation
boolean
default:"false"
Skip transaction simulation. Faster but no pre-flight validation. Only set true if you handle validation yourself.

Example

curl -X POST "https://api.argyros.xyz/api/v1/swap" \
  -H "Content-Type: application/json" \
  -d '{
    "userWallet": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
    "inputMint": "So11111111111111111111111111111111111111112",
    "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": "1000000000",
    "swapMode": "ExactIn",
    "slippageBps": 50
  }'

Response

{
  "success": true,
  "data": {
    "transaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAHEAo...",
    "lastValidBlockHeight": 245832190,
    "amountIn": "1000000000",
    "amountOut": "145320000",
    "minAmountOut": "144593400",
    "feeAmount": "0",
    "simulation": {
      "success": true,
      "logs": [],
      "computeUnitsConsumed": 85000,
      "insufficientFunds": false,
      "slippageExceeded": false
    },
    "computeUnitsEstimate": 85000,
    "route": [
      "So11111111111111111111111111111111111111112",
      "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
    ],
    "hopCount": 1,
    "pools": ["HJPjoWUrhoZzkNfRpHuieeFk9WcZWjwy6PBjZ81ngndJ"],
    "isSplitRoute": false
  }
}

Response fields

transaction
string
Base64-encoded unsigned transaction. Deserialize, sign, and submit.
lastValidBlockHeight
integer
Transaction expires after this block height (~60 seconds from creation).
amountIn
string
Input amount in smallest units.
amountOut
string
Estimated output amount in smallest units.
minAmountOut
string
Minimum output after slippage (ExactIn only). Transaction reverts if actual output is less.
maxAmountIn
string
Maximum input after slippage (ExactOut only). Transaction reverts if actual input exceeds this.
feeAmount
string
Aggregator fee in output token units.
simulation
object
Simulation result (omitted if skipSimulation: true).
computeUnitsEstimate
integer
Estimated compute units for execution.
route
string[]
Token path from input to output.
hopCount
integer
Number of swap hops.
pools
string[]
Pool addresses used, in execution order.
isSplitRoute
boolean
Whether liquidity is split across multiple pools.
splitPercents
integer[]
Percentage split per pool (only if isSplitRoute is true).

Simulation

By default, the API simulates the transaction before returning it. This catches common issues early:
simulation fieldMeaningWhat to do
insufficientFunds: trueWallet doesn’t have enough tokens or SOL for feesShow balance error to user
slippageExceeded: truePrice changed between quote and transaction buildRetry with a fresh quote
success: false + errorOther simulation failureCheck logs for details
Set skipSimulation: true only if you need lower latency and handle validation yourself.

What’s next

After receiving the transaction, sign and submit it.