Laserstream is currently in private beta and not yet publicly available. Access is limited, and some features may still be under development.

Overview

Laserstream offers Enhanced WebSockets (distinct from standard Solana WebSockets), delivering faster response times and additional filters. Current methods:

  • transactionSubscribe
  • accountSubscribe

WebSockets have a 10-minute inactivity timer. Use health checks or send pings every minute to keep the connection alive.

Looking for Atlas WebSockets?
If you need information on Atlas Enhanced WebSockets, please see our Disclaimer.


Quickstart

1. Create a Basic WebSocket Client

mkdir laserstream-enhanced-ws-demo
cd laserstream-enhanced-ws-demo
npm init -y
npm install ws

(You only need the ws library for a Node.js WebSocket client. No additional libraries are strictly required.)

2. Obtain Your API Key

Generate a key from the Helius Dashboard.

3. Minimal Code Example

Create an index.js file:

// index.js

const WebSocket = require('ws');

// 1. Use the Laserstream Enhanced WebSockets endpoint (Mainnet example):
const WS_URL = `laserstream-ws-url`;

const ws = new WebSocket(WS_URL);

// 2. Define a transactionSubscribe request for real-time token transactions
// Replace "accountInclude" with any accounts you want to track
function buildSubscriptionRequest() {
  return {
    jsonrpc: "2.0",
    id: 1,
    method: "transactionSubscribe",
    params: [
      {
        vote: false,
        failed: false,
        accountInclude: ["TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"],
        accountExclude: [],
        accountRequired: []
        // You can add "signature" or "fromSlot" if needed
      },
      {
        commitment: "confirmed",
        encoding: "jsonParsed",
        transactionDetails: "full",
        showRewards: false,
        maxSupportedTransactionVersion: 0
        // fromSlot: 224339000 // Uncomment for replay from a specific slot
      }
    ]
  };
}

// 3. Optional: Keep the connection alive (ping every 30s)
function startPing(ws) {
  setInterval(() => {
    if (ws.readyState === WebSocket.OPEN) {
      ws.ping();
      console.log("Ping sent");
    }
  }, 30000);
}

// 4. Set up WebSocket event handlers
ws.on('open', () => {
  console.log("Enhanced WebSocket is open");
  // Send the subscription request
  const request = buildSubscriptionRequest();
  ws.send(JSON.stringify(request));
  startPing(ws);
});

ws.on('message', (data) => {
  try {
    const msg = JSON.parse(data);
    console.log("Received:", msg);
  } catch (e) {
    console.error("Failed to parse JSON:", e);
  }
});

ws.on('error', (err) => {
  console.error("WebSocket error:", err);
});

ws.on('close', () => {
  console.log("WebSocket is closed");
});

4. Replace Your Endpoint and API Key

Replace the placeholder laserstream-ws-url with your actual WebSocket URL, and include your api-key as follows:

const WS_URL = `wss://<YOUR_ENDPOINT>/?api-key=<YOUR_API_KEY>`;

Make sure to use the key you obtained from the Helius Dashboard.

5. Run and View Results

node index.js

You’ll start receiving transaction events whenever confirmed token transactions involve TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA. Expect JSON objects showing transaction details and slots.


Transaction Subscribe

The transactionSubscribe websocket method enables real-time transaction events. To use it, provide a TransactionSubscribeFilter and optionally include TransactionSubscribeOptions for further customization.

TransactionSubscribeFilter

vote: A boolean flag to include/exclude vote-related transactions.

failed: A boolean flag to include/exclude transactions that failed.

signature: Filters updates to a specific transaction based on its signature.

accountInclude: A list of accounts for which you want to receive transaction updates. This means that only one of the accounts must be included in the transaction updates (e.g., Account 1 OR Account 2).

accountExclude: A list of accounts you want to exclude from transaction updates.

accountRequired: Transactions must involve these specified accounts to be included in updates. This means that all of the accounts must be included in the transaction updates (e.g., Account 1 AND Account 2).

You can include up to 50,000 addresses in the accountsInclude, accountExclude and accountRequired arrays.

TransactionSubscribeOptions (Optional)

commitment: Specifies the commitment level for fetching data, dictating at what stage of the transaction lifecycle updates are sent. The possible values are processed, confirmed and finalized

encoding: Sets the encoding format of the returned transaction data. The possible values are base58, base64 and jsonParsed

transactionDetails : Determines the level of detail for the returned transaction data. The possible values are full, signatures, accounts and none

showRewards: A boolean flag indicating if reward data should be included in the transaction updates.

maxSupportedTransactionVersion: Specifies the highest version of transactions you want to receive updates. To get Versioned Transactions, set the value to 1.

fromSlot: Begin the subscription from a specific Solana slot, replaying any relevant transactions from that slot forward until you catch up to real-time data.

maxSupportedTransactionVersion is required to return the accounts and full-level details of a given transaction (i.e., transactionDetails: "accounts" | "full").

Transaction Subscribe Example


Account Subscribe

Solana’s Websockets supports a method that allows you to subscribe to an account and receive notifications via the websocket connection whenever there are changes to the lamports or data associated with a matching account public key. This method aligns directly with the Solana Websocket API specification.

Parameters

string: The account public key, sent in base58 format (required).

object: An optional object used to pass additional parameters.

  • encoding: Specifies the format for data returned in the AccountNotification. Supported values: base58, base64, base64+zstd, jsonParsed (default is base58).
  • commitment: Defines the commitment level for the transaction. Supported values: finalized, confirmed, processed (default is finalized).
  • fromSlot: Replay from this slot, receiving historical changes for the account up to the current slot.

Account Subscribe Example


Disclaimer: Atlas Enhanced WebSockets

Atlas Enhanced WebSockets will be powered by Laserstream under the hood. This means you can continue using the same Atlas endpoints, and you’ll still have access to Laserstream’s advanced capabilities—such as fromSlot replay—without needing to migrate. If you’re already on Atlas, no changes are required; if you prefer the dedicated Laserstream endpoints, you can use those as well.