For the complete documentation index, see llms.txt. This page is also available as Markdown.

Signing & submitting

How to decode, sign, and submit the transactions the API builds.

There's no API key and the server never holds your keys. Every transaction-builder endpoint returns an unsigned, base64-encoded versioned transaction (v0). You decode it, sign it client-side, and submit it yourself.

Which RPC?

Route each transaction to the correct endpoint or it will fail:

Transaction kind
Endpoints
Submit to

Account & funds

init-*, deposit, deposit-direct, delegate-basket, withdraw, custody-settlement, withdrawal-settle, request-withdrawal

your Solana RPC

Trading

open/close/increase/decrease/reverse-position, collateral, triggers, limits

the v2 RPC endpoint

Set both up front:

export SOLANA_RPC_URL="https://api.mainnet-beta.solana.com"
export V2_RPC_URL="<v2-rpc-endpoint>"

Decode, sign, submit

import { VersionedTransaction, Connection } from "@solana/web3.js";

async function buildSignSubmit(path, body, signers, rpcUrl) {
  const res = await fetch(`${FLASH_API_URL}${path}`, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify(body),
  });
  const data = await res.json();
  if (data.err) throw new Error(data.err);           // compute error in a 200 body
  if (!data.transactionBase64) throw new Error("preview-only or no tx");

  const tx = VersionedTransaction.deserialize(
    Buffer.from(data.transactionBase64, "base64")
  );
  tx.sign(signers);

  const connection = new Connection(rpcUrl, "confirmed");
  const sig = await connection.sendRawTransaction(tx.serialize());
  await connection.confirmTransaction(sig, "confirmed");
  return sig;
}

// Trade → v2 RPC
await buildSignSubmit("/transaction-builder/open-position", openReq, [owner], V2_RPC_URL);
// Funds op → Solana RPC
await buildSignSubmit("/transaction-builder/deposit", depositReq, [owner], SOLANA_RPC_URL);

Who signs

  • Owner signs almost everything.

  • Withdrawals (withdraw, request-withdrawal) also need a fee payer that differs from owner — the delegation program rejects owner == feePayer. The client holds that keypair and co-signs. See Withdraw funds.

Preview-only mode

open-position returns its quote without a transaction when you omit owner (transactionBase64: null). The preview/* endpoints compute fees, exit fees, TP/SL PnL, and margin changes without building a transaction at all.

Two error surfaces

Always check both — see Errors:

  • HTTP failures return { "error": "…" } (e.g. 400 invalid pubkey, 404 unknown market/symbol).

  • Compute failures on quote endpoints come back 200 with { "err": "…" } in the body.

Blockhash expiry

Built transactions embed a recent blockhash that expires in ~45s. On "Blockhash not found / expired," re-call the builder for a fresh transaction and submit immediately. Trading endpoints refresh the blockhash between calls so back-to-back builds don't collide.

Last updated

Was this helpful?