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

# How to Use preconfSubscribe

> Stream scheduled Solana transactions at the lowest possible latency with the preconfSubscribe WebSocket method. Subscribe, decode the payload, and react before transactions land.

<Tip>
  **Use [Sender Max](/sending-transactions/sender-max) (min tip: 0.001 SOL) to
  act on Pre Confirmations.** A pre-confirmation only pays off if you land your
  transaction
  first — Sender Max is the fastest way to do that. Build on Sender Max from the
  start to get the full benefit of Pre Confirmations.
</Tip>

## What is `preconfSubscribe`?

`preconfSubscribe` is a Helius WebSocket method that streams [Pre Confirmations](/pre-confirmations/overview) — transactions delivered at the scheduled-transaction stage, before they are shredded. It is the lowest-latency transaction signal Helius offers.

<Note>
  The stream is not continuous. Coverage scales with the share of stake
  forwarding to Helius, so expect slots with no messages — handle these gaps
  gracefully. See [Coverage](/pre-confirmations/overview#coverage).
</Note>

`preconfSubscribe` is served from `wss://beta.helius-rpc.com` — the Helius [Gatekeeper](/gatekeeper/overview) endpoint — rather than `mainnet.helius-rpc.com`. Authenticate with your API key as a query parameter.

```
wss://beta.helius-rpc.com/?api-key=<API_KEY>
```

<Note>
  The `beta` hostname refers to the [Gatekeeper](/gatekeeper/overview) rollout,
  not the maturity of Pre Confirmations. Pre Confirmations launch on the
  Gatekeeper endpoint first; it will become the standard endpoint as Helius
  migrates traffic to Gatekeeper.
</Note>

## Subscribe

Send a JSON-RPC request with the `preconfSubscribe` method. The server responds with a subscription ID, then streams a notification for each scheduled transaction.

```json theme={"system"}
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "preconfSubscribe"
}
```

### Subscribe Response

```json theme={"system"}
{
  "jsonrpc": "2.0",
  "result": 24040,
  "id": 1
}
```

Store the `result` — it is the subscription ID you use to [unsubscribe](#unsubscribing). After this acknowledgement, notifications stream as binary frames (see below).

## Notification payload

Notifications are delivered as **binary** WebSocket frames (not JSON). Each frame is a packed byte layout carrying a single scheduled transaction:

| Bytes | Field         | Type                            | Description                                                                                                                                                    |
| ----- | ------------- | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 0     | `version`     | `u8`                            | Payload schema version. Currently `1`.                                                                                                                         |
| 1–8   | `slot`        | `u64` (little-endian)           | The slot the transaction is scheduled in.                                                                                                                      |
| 9–16  | `tx_index`    | `u64` (little-endian)           | Index of the transaction within the slot.                                                                                                                      |
| 17    | `status`      | `u8`                            | Transaction status: `0` = failed, `1` = success, `2` = unknown. Execution status is reported by validators on a best-effort basis — `2` when it's unavailable. |
| 18+   | `transaction` | `bincode(VersionedTransaction)` | The scheduled transaction, bincode-serialized.                                                                                                                 |

Read the fields in order, then [`bincode`](https://docs.rs/bincode)-deserialize the remaining bytes into a `VersionedTransaction` to read instructions, accounts, and the signature.

<Warning>
  **Always read and check the `version` byte first.** It is currently `1`. If
  Helius needs to update the payload format, the version will increment — branch
  on it so your decoder keeps working across schema changes.
</Warning>

<Note>
  A pre-confirmation is an early signal, not a guarantee. The transaction has not
  yet landed onchain and could still fail or be dropped. Confirm landing through
  standard commitment checks before treating it as final.
</Note>

## Example

```javascript theme={"system"}
const WebSocket = require('ws');

const ws = new WebSocket('wss://beta.helius-rpc.com/?api-key=<API_KEY>');

ws.on('open', () => {
  ws.send(JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'preconfSubscribe'
  }));

  // Keep the connection alive
  setInterval(() => ws.ping(), 30_000);
});

ws.on('message', (data, isBinary) => {
  // The subscribe acknowledgement arrives as a JSON text frame
  if (!isBinary) {
    const msg = JSON.parse(data.toString());
    if (msg.id === 1) console.log('Subscribed, ID:', msg.result);
    return;
  }

  // Notifications arrive as binary frames:
  // version (u8) | slot (u64 LE) | tx_index (u64 LE) | status (u8) | bincode(VersionedTransaction)
  const buf = Buffer.from(data);
  const version = buf.readUInt8(0); // currently 1 — branch on this if it changes
  if (version !== 1) return; // unknown schema version; update your decoder
  const slot = buf.readBigUInt64LE(1);
  const txIndex = buf.readBigUInt64LE(9);
  const status = buf.readUInt8(17); // 0 = failed, 1 = success, 2 = unknown
  const txBytes = buf.subarray(18); // bincode-serialized VersionedTransaction

  console.log('Scheduled transaction:', { version, slot, txIndex, status, bytes: txBytes.length });
  // Deserialize txBytes (bincode) into a VersionedTransaction with your Solana tooling
});

ws.on('error', console.error);
ws.on('close', () => process.exit(1));
```

## Unsubscribing

To stop receiving notifications, call `preconfUnsubscribe` with the subscription ID returned from `preconfSubscribe`.

```json theme={"system"}
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "preconfUnsubscribe",
  "params": [24040]
}
```

```json theme={"system"}
{
  "jsonrpc": "2.0",
  "result": true,
  "id": 2
}
```

## Pricing

Pre Confirmations cost **10 credits per message** — one message per streamed transaction — billed from your plan. See [Credits](/billing/credits) for details.

<Note>
  Pre Confirmations is a new product and pricing is subject to change.
</Note>

## Related

<CardGroup cols={2}>
  <Card title="Pre Confirmations Overview" icon="bolt" href="/pre-confirmations/overview">
    What Pre Confirmations are and where they sit in the validator pipeline.
  </Card>

  <Card title="transactionSubscribe" icon="tower-broadcast" href="/rpc/websocket/transaction-subscribe">
    Stream confirmed-commitment transactions with rich filtering.
  </Card>
</CardGroup>
