services
07

Build a transaction (the swap method)

an unsigned transaction you sign and send through any RPC

Send a quoteId and the signing wallet; get one unsigned transaction. A v1 (quote asked txVersion: 1) puts the message before the signatures: sign it with a v1-capable SDK (web3.js 3.0, kit 8.4) and read it with getTransaction maxSupportedTransactionVersion 1. Send with sendTransaction (skipPreflight: true) on any RPC, then confirm with getTransaction.

carbium://swap · swap.sh
# swap method: the unsigned transaction for a quoteId, which you sign and sendcurl https://services.carbium.sh \  -H 'content-type: application/json' -H 'x-api-key: <YOUR_KEY>' \  -d '{"jsonrpc":"2.0","id":1,"method":"swap","params":[{        "quote_id":"65a5c08fd08b79ea9ffd4290a229a5fb",        "user_pubkey":"<YOUR_PUBKEY>",        "compute_unit_price_micro_lamports":10000}]}'# -> {"jsonrpc":"2.0","result":{#     "transaction":"AQAAAAAA...",#     "blockhash":"81rLLeUpqEwSf2ULSrPDiUFjSVuvz15VcEChu56ieJD7","lastValidBlockHeight":432979660,#     "minAmountOut":"109035778","computeUnitLimit":224249,"priorityFeeLamports":"2243",#     "rentLamports":"1488440","ataCreates":1},"id":1}# after a reroute the result also carries "routeRerouted":{"why":"pool_state_missing","deadPool":"<pool>","quotedOut":"109583697","reroutedOut":"109401234","floor":"109035778"}# Sign it as user_pubkey, send it with sendTransaction (skipPreflight: true), confirm with getTransaction.

request and result

swap/shape
fieldtypemeaning
params · positional [{...}] or by name
quote_id32 hexquoteId from quote, within 30 s
user_pubkeybase58wallet that signs and pays
compute_unit_price_micro_lamports0 to 300000, optionalpriority price per compute unit. Omitted: the 75th percentile of recent priority fees on the router's busiest pools, refreshed every 10 s, held within 10,000 to 300,000, 10,000 when the sample is over 60 s old. A value you pass always wins, 0 included
result
transactionstringunsigned, base64: v0 with lookup tables by default, v1 without when the quote asked txVersion: 1
txVersionnumber; v1 only1 on a v1 build; absent on v0
blockhash, lastValidBlockHeightstring, numberblockhash, and the height it expires at
minAmountOutstringfloor it enforces
computeUnitLimit, priorityFeeLamportsnumber, stringcompute limit, and priority fee: limit × price (yours, or the network's) ÷ 1,000,000, rounded up on v0, down on v1 (which carries the fee in lamports)
rentLamports, ataCreatesstring or null, numbermax rent for the token accounts it creates (refundable on close), and their count
routeReroutedobject; after a reroute only{why, deadPool, quotedOut, reroutedOut, floor}: why the refusal behind it (pool_state_missing, pool_keys_missing, fee_recipient_ata_missing, pcurve_graduated, transaction_too_large or accounts_over_cap); deadPool the pool held out for 30 s, absent when the route was too large or over the cap; quotedOut the quote's destAmountOut; reroutedOut the new expected out; floor equals minAmountOut. Amounts are strings
swapTagnumber; tagged only1 when asked; absent otherwise. No plain form: -32093, error.data.code swap_tag_unroutable; pin dex, change the amount, or quote without swapTag
!If a quoted pool is gone at build time, or the route does not fit one transaction or the quote's account cap, swap quotes once more at the same srcAmountIn, dex, txVersion, swapTag and maxAccounts, avoiding that pool or route, and builds at the same minAmountOut with routeRerouted set. The transaction then does not follow the quote's routePlan, and the fill may land below destAmountOut, never below the floor. If the new quote pays less, changes the amount or does not build, swap returns the first refusal at HTTP 200 (-32081, -32083, -32055 or -32093): quote again. The signing wallet pays network and priority fees, rent for token accounts it creates, and platformFee: as quoted when it comes off the input; on SOL out, or USDC or USDT out with no SOL in, feeBps of the delivered output, so it moves with the fill.

refusals

swap/refusals
codehttpmeaning
fix the request
-32602400quote_id and user_pubkey required; compute_unit_price_micro_lamports a whole number 0 to 300000; nothing else is read
-32600400quote is not batchable: one swap per request
quote again
-32095400quote_id unknown or past 30 s
-32074400route has a family the builder will not build: pin others with dex
-32081 … -32083, -32096200route cannot be built now (pool not loaded, mint not resolvable, transaction too large, a leg that would fail on chain)
-32093200 or 503builder refused, reason in error.data.code: at 200 quote again, at 503 retry
-32098200hook admits only wallets holding its gate token; error.data: gate_mint, gate_min (base units), holding, gate_decimals
-32099200builder cannot derive the route's hook account; final for this quote
-32055200route over the quote's account cap, already re-routed once under it: quote again with a higher cap or a smaller amount_in
-32056503builder refused the quote's account cap: quote again, never the same quote_id
retry later
-32011, -32060 … -32097 (the rest)503retry with backoff

methods

swapreturns {transaction (unsigned, base64), blockhash, lastValidBlockHeight, minAmountOut, computeUnitLimit, priorityFeeLamports, rentLamports, ataCreates, txVersion?, routeRerouted?, swapTag?}