Swap Building
The swap build endpoint returns an unsigned VersionedTransaction that you sign client-side and submit back.
Flow
1. POST /v1/swap/build → unsigned TX (base64)
2. Sign with your wallet (client-side)
3. POST /v1/swap → submit through Venum's landing fan-outNon-Custodial
Venum never touches your private keys. The transaction is built with your public key as the signer, returned unsigned, and you sign it locally. We only see the signed transaction when you submit it.
Request
POST /v1/swap/build{
"inputMint": "So11111111111111111111111111111111111111112",
"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": "1000000000",
"slippageBps": 100,
"userPublicKey": "YourWalletPublicKeyBase58"
}What's in the Transaction
The returned transaction contains:
- Compute budget —
SetComputeUnitLimitsized per DEX type (200K-600K) - ATA management — optional associated token account creation when needed
- Native SOL wrap/unwrap — when the route starts or ends in SOL
- Swap instruction(s) — the actual DEX swap path
Quote ID
The response includes a quoteId that's valid for 30 seconds. You must include this when submitting the signed transaction so Venum can tie the submission back to the built route.
{
"transaction": "AQAAAA...base64...==",
"quoteId": "q_42_1712000000000",
"estimatedOutput": "134520000",
"minOutput": "133174800",
"feeLamports": "0",
"feeBps": 0,
"computeUnits": 400000
}Verify before signing (recommended)
The build response includes an attestation — a detached Ed25519 signature from Venum over the transaction bytes and the swap summary. Verifying it against Venum's pinned key catches a response tampered in transit (a swapped destination, widened slippage, a redirected output) before you sign. Venum signs; you verify. See Response attestation for the message format and a verification snippet, and GET /v1/attestation/pubkey for the key to pin.
Signing Example
import { VersionedTransaction } from '@solana/web3.js';
// Decode the unsigned transaction
const txBytes = Buffer.from(response.transaction, 'base64');
const tx = VersionedTransaction.deserialize(txBytes);
// Sign with your keypair
tx.sign([yourKeypair]);
// Encode back to base64 for submission
const signedBase64 = Buffer.from(tx.serialize()).toString('base64');