Skip to content

Composable Instructions

Venum's key differentiator: you get TransactionInstruction[], not a serialized blob.

The Problem with Jupiter

Jupiter API returns a fully serialized, opaque transaction. You can't:

  • Add your own fee instruction
  • Compose with a CPI (cross-program invocation)
  • Bundle with other instructions in the same transaction
  • Modify the compute budget
  • Add a memo or custom program call

You either use their blob as-is, or you don't use it at all.

Venum's Approach

The /v1/swap/build endpoint returns an unsigned VersionedTransaction that you can deserialize, inspect, and compose with your own instructions before signing:

javascript
// 1. Get the best route
const { routes } = await fetch('https://api.venum.dev/v1/quote', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'X-API-Key': API_KEY },
  body: JSON.stringify({ inputMint: 'SOL', outputMint: 'USDC', amount: '1000000000' }),
}).then(r => r.json());

// 2. Build the transaction — returns base64-encoded unsigned TX
const { transaction } = await fetch('https://api.venum.dev/v1/swap/build', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'X-API-Key': API_KEY },
  body: JSON.stringify({ route: routes[0], userPublicKey: wallet.publicKey.toString() }),
}).then(r => r.json());

// 3. Deserialize, add your own instructions, sign, submit
const tx = VersionedTransaction.deserialize(Buffer.from(transaction, 'base64'));
tx.sign([wallet]);

const { signature } = await fetch('https://api.venum.dev/v1/send', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json', 'X-API-Key': API_KEY },
  body: JSON.stringify({ transaction: Buffer.from(tx.serialize()).toString('base64') }),
}).then(r => r.json());

Use Cases

  • Telegram bots — Add your own fee instruction to every swap
  • dApps — Compose swap with your protocol's CPI
  • Wallets — Bundle swap with account creation / closing
  • Trading bots — Combine swap with Jito tip instruction
  • Aggregators — Multi-hop through different DEXes in one TX