Signing & submitting
How to decode, sign, and submit the transactions the API builds.
Which RPC?
Transaction kind
Endpoints
Submit to
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
Preview-only mode
Two error surfaces
Blockhash expiry
Last updated
Was this helpful?

