> For the complete documentation index, see [llms.txt](https://docs.flash.trade/flash-trade/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/signing-and-submitting.md).

# Signing & submitting

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:

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

## Decode, sign, submit

```typescript
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](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/guides/withdraw-funds.md).

## Preview-only mode

`open-position` returns its quote without a transaction when you omit `owner` (`transactionBase64: null`). The [`preview/*`](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/reference/previews.md) 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](/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/errors.md):

* **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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flash.trade/flash-trade/flash-trade-protocol/build-on-flash/flash-trade-v2/signing-and-submitting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
