Skip to content

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-out

Non-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

bash
POST /v1/swap/build
json
{
  "inputMint": "So11111111111111111111111111111111111111112",
  "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
  "amount": "1000000000",
  "slippageBps": 100,
  "userPublicKey": "YourWalletPublicKeyBase58"
}

What's in the Transaction

The returned transaction contains:

  1. Compute budgetSetComputeUnitLimit sized per DEX type (200K-600K)
  2. ATA management — optional associated token account creation when needed
  3. Native SOL wrap/unwrap — when the route starts or ends in SOL
  4. 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.

json
{
  "transaction": "AQAAAA...base64...==",
  "quoteId": "q_42_1712000000000",
  "estimatedOutput": "134520000",
  "minOutput": "133174800",
  "feeLamports": "0",
  "feeBps": 0,
  "computeUnits": 400000
}

Signing Example

typescript
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');