> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tracefall.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Sending

> Send a transaction over JSON-RPC, Jito's paths, the fast path, REST or a WebSocket.

Four ways in, all to the same place. They can be mixed.

| Protocol | Use it when | Per transaction |
| - | - | - |
| [JSON-RPC](#json-rpc) | you want to change one URL and nothing else, from an RPC client or a Jito SDK | one HTTP request |
| [Fast path](#fast-path) | you send from a web page, or want the least per request | one HTTP request: the bytes, no header |
| [REST](#rest) | you want one transaction per request with a JSON answer | one HTTP request |
| [WebSocket](#websocket) | you send many transactions from one process or one page | one frame on an open connection |

Each takes a fully signed legacy, v0 or v1 transaction that pays a tip to one of our
[tip accounts](https://docs.tracefall.xyz/tip-accounts.md). The examples below send with no key; to add yours, see [Authentication](https://docs.tracefall.xyz/authentication.md).

## JSON-RPC

`POST /` speaks the JSON-RPC of a Solana RPC node for these methods:

| Method | What it does |
| - | - |
| `sendTransaction` | Sends one transaction. The result is its signature |
| `sendBundle` | Sends 1 to 4 transactions as one bundle ([Bundles](https://docs.tracefall.xyz/bundles.md)) |
| `getTipAccounts` | The eight tip accounts |
| `getHealth` | `"ok"`, as an RPC node answers it |

```bash theme={null}
curl -s https://sender.tracefall.xyz \
  -H 'Content-Type: application/json' \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "sendTransaction",
    "params": ["<base64 transaction>", {"encoding": "base64", "bundleOnly": false}]
  }'
```

```json theme={null}
{"jsonrpc": "2.0", "id": 1, "result": "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW"}
```

* `encoding` is `base64` or `base58`. As on an RPC node, it is `base58` when you leave it out. **Send `base64`**: it is
  smaller and faster to read. Base58 is accepted for transactions of up to 1,232 bytes.
* `bundleOnly: true` sends your transaction only inside bundles ([bundleOnly](https://docs.tracefall.xyz/bundle-only.md)).
* `skipPreflight`, `maxRetries`, `preflightCommitment` and `minContextSlot` are accepted and ignored. We never simulate.
* A batch, a JSON array of up to 32 calls, is answered as a batch: one answer per call.
* Any other method answers `-32601` (method not found). Keep reads and confirmations on your own RPC node.

With `@solana/web3.js`, use a second `Connection` for sends only. `sendRawTransaction` sends base64 by itself:

```ts theme={null}
import { Connection } from '@solana/web3.js';

const rpc = new Connection(YOUR_RPC_URL);                       // reads and confirmations
const sender = new Connection('https://sender.tracefall.xyz');  // sends

const signature = await sender.sendRawTransaction(tx.serialize(), { skipPreflight: true });
```

### Jito-compatible paths

`POST /api/v1/transactions` and `POST /api/v1/bundles` answer the same JSON-RPC as `POST /`, at the paths of Jito's
block engine. A client built on Jito's SDKs switches by changing its base URL to `https://sender.tracefall.xyz`.

```bash theme={null}
curl -s "https://sender.tracefall.xyz/api/v1/transactions?bundleOnly=true" \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"sendTransaction","params":["<base64 transaction>",{"encoding":"base64"}]}'
```

* `?bundleOnly=true` on `/api/v1/transactions` sends with [bundleOnly](https://docs.tracefall.xyz/bundle-only.md).
* Your transactions still tip one of **our** tip accounts. A Jito tip alone is refused with `tip_missing`.
* Methods we do not serve, such as `getBundleStatuses`, answer `-32601`. The bundle id `sendBundle` answers identifies
  the bundle to us only ([Bundles](https://docs.tracefall.xyz/bundles.md)).

## Fast path

`POST /v1/tx` is the least there is to send. The body is the signed transaction, and nothing else is needed.

```bash theme={null}
curl -s "https://sender.tracefall.xyz/v1/tx" --data-binary @transaction.bin
# accepted
```

* **The body** is the transaction's raw bytes, or the same in base64. We tell them apart ourselves: no `Content-Type` is
  read.
* **A key** goes in the URL, `?api-key=<key>`, so that no header is needed. `?bundle-only=true` sends it only inside
  bundles.
* **The answer** is a status and one word, as text: `200 accepted`, `200 duplicate`, or a refusal's code alone under
  its status, such as `400 tip_too_small` or `429 rate_limited` ([Errors](https://docs.tracefall.xyz/errors.md)). It holds no JSON, no message and
  no signature: you have your transaction's.
* **The rate headers** come with every answer once your rate is checked, and a web page may read them
  ([Limits](https://docs.tracefall.xyz/limits.md#rates)).

**From a web page, use this one.** A browser asks the server first (a CORS preflight, one more round trip) before a
request with an `Authorization` header or a JSON or binary content type. A `POST` with no header of your own is not
asked about. A key in a web page is public: send keyless from a page, or with a key limited per visitor address
([Keys in a web page](https://docs.tracefall.xyz/authentication.md#keys-in-a-web-page)).

```ts theme={null}
// One request, no preflight. `keepalive` lets it finish even if the page is closing.
const body = new Uint8Array(tx.serialize());
const res = await fetch('https://sender.tracefall.xyz/v1/tx', { method: 'POST', body, keepalive: true });
if (!res.ok) console.warn('not taken:', await res.text());
```

## REST

`POST /v1/transactions` takes one transaction, as raw bytes or as JSON.

```bash Raw bytes theme={null}
curl -s "https://sender.tracefall.xyz/v1/transactions" \
  -H 'Content-Type: application/octet-stream' \
  --data-binary @transaction.bin
```

```bash JSON theme={null}
curl -s https://sender.tracefall.xyz/v1/transactions \
  -H 'Content-Type: application/json' \
  -d '{"transaction": "<base64 transaction>", "bundleOnly": false}'
```

```json theme={null}
{"signature": "5VERv8…kQUW", "status": "accepted"}
```

`status` is `accepted`, or `duplicate` when we already took this signature ([Sending again](https://docs.tracefall.xyz/sending-again.md)). With raw
bytes, `?bundle-only=true` sends it only inside bundles. A refusal answers an HTTP status and an `error` object, with
the transaction's `signature` beside it when we could read one:

```json theme={null}
{
  "signature": "5VERv8…kQUW",
  "error": {"code": "tip_too_small", "message": "the tip is 50,000 lamports; the minimum is 100,000 lamports (0.0001 SOL)"}
}
```

## WebSocket

Connect once to `wss://sender.tracefall.xyz/v1/ws`, with your key in a header or as `?api-key=<key>`, and send one
message per transaction. A message is one of:

* a **text frame** with JSON: `{"id": 1, "transaction": "<base64 transaction>", "bundleOnly": false}`. `id` is echoed in
  the answer, so you can match answers to requests. It may be a number or a string. `bundleOnly` may be left out.
* a **binary frame** holding the raw transaction. Its answer has `"id": null`.
* a text frame with a JSON-RPC call, answered as JSON-RPC.

Every message gets exactly one answer, in the order the messages were read:

```json theme={null}
{"id": 1, "status": "accepted", "signature": "5VERv8…kQUW"}
{"id": 2, "status": "duplicate", "signature": "5VERv8…kQUW"}
{"id": 3, "status": "rejected", "signature": null, "code": "tip_missing", "message": "no transfer to a tip account"}
```

```ts theme={null}
const ws = new WebSocket('wss://sender.tracefall.xyz/v1/ws');
const pending = new Map<number, (answer: unknown) => void>();
let next = 1;

ws.onmessage = (m) => {
  const answer = JSON.parse(m.data);
  pending.get(answer.id)?.(answer);
  pending.delete(answer.id);
};

function send(tx: Uint8Array): Promise<unknown> {
  const id = next++;
  ws.send(JSON.stringify({ id, transaction: btoa(String.fromCharCode(...tx)) }));
  return new Promise((resolve) => pending.set(id, resolve));
}
```

* We ping every 30 seconds; standard clients answer by themselves. A connection with no frame for 120 seconds is
  closed. Reconnect and carry on.
* A message is held to the sizes of a request body ([Limits](https://docs.tracefall.xyz/limits.md#sizes)).
* If your key is revoked, the next message is answered `unauthorized`.

## v1 and durable-nonce transactions

Both are accepted, and both travel on fewer paths than other transactions:

* **v1 transactions** go only on the paths confirmed to take them, which may be RPC nodes alone. One larger than 1,232
  bytes is never sent straight to leaders. Sent with `bundleOnly` when no bundle can carry it, a v1 transaction is
  refused with `bundle_unavailable`.
* **Durable-nonce transactions** are not carried in the bundles we send for you: they go out as plain copies. Sent with
  `bundleOnly`, one is refused with `nonce_not_bundled`.

The [status lookup](https://docs.tracefall.xyz/api-reference/status/look-up-a-transaction.md) shows which paths a transaction took.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.