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

Overview

Laserstream’s gRPC offering builds on a Yellowstone-based interface and enhances it with features like historical replay, multi-node failover, and a fully managed environment. You can connect either directly with @yellowstone-grpc or use the higher-level Helius Laserstream client for added benefits (auto-reconnect, subscription management, error handling, etc.).

Quickstart

1

Create a New Project

mkdir laserstream-grpc-demo
cd laserstream-grpc-demo
npm init -y
2

Install Dependencies

npm install helius-laserstream
npm install --save-dev typescript ts-node
npx tsc --init
3

Obtain Your API Key

Generate a key from the Helius Dashboard.

4

Create a Subscription Script

Create index.ts with the following:

import { subscribe, CommitmentLevel, LaserstreamConfig, SubscribeRequest } from 'helius-laserstream'

async function main() {
  const subscriptionRequest: SubscribeRequest = {
    transactions: {
      client: {
        accountInclude: ['TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'],
        accountExclude: [],
        accountRequired: [],
        vote: false,
        failed: false
      }
    },
    commitment: CommitmentLevel.CONFIRMED,
    accounts: {},
    slots: {},
    transactionsStatus: {},
    blocks: {},
    blocksMeta: {},
    entry: {},
    accountsDataSlice: [],
    // Optionally, you can replay missed data by specifying a fromSlot:
    // fromSlot: '224339000'
    // Note: Currently, you can only go back up to 3000 slots.
  };

// TODO: Replace the values below with your actual Laserstream API key and endpoint
const config: LaserstreamConfig = {
  apiKey: 'your-api-key',
  endpoint: 'your-endpoint',
}

  await subscribe(config, subscriptionRequest, async (data) => {
    
    console.log(data);

  }, async (error) => {
    console.error(error);
  });
}

main().catch(console.error);
5

Replace Your Endpoint and API Key

In index.ts, update the config object with the actual apiKey and endpoint from your Helius Dashboard:

const config: LaserstreamConfig = {
  apiKey: 'YOUR_ACTUAL_API_KEY',
  endpoint: 'YOUR_ACTUAL_ENDPOINT',
}
6

Run and View Results

npx ts-node index.ts

Whenever a confirmed token transaction involves TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA, you’ll see the data in your console.

Subscribe Request

In the subscribe request, you need to include the following:

const subscriptionRequest: SubscribeRequest = {
  commitment: CommitmentLevel.CONFIRMED,
  accountsDataSlice: [],
  transactions: {},
  accounts: {},
  slots: {},
  blocks: {},
  blocksMeta: {},
  entry: {},
}

Next, you’ll need to specify the filters for the data you want to subscribe to, such as accounts, blocks, slots, or transactions.

Code Examples

import { subscribe, CommitmentLevel, LaserstreamConfig, SubscribeRequest } from 'helius-laserstream'

async function main() {
  const subscriptionRequest: SubscribeRequest = {
    transactions: {},
    commitment: CommitmentLevel.CONFIRMED,
    accounts: {},
    slots: {
      slot: { filterByCommitment: true },
    },
    transactionsStatus: {},
    blocks: {},
    blocksMeta: {},
    entry: {},
    accountsDataSlice: [],
  }


 const config: LaserstreamConfig = {
    apiKey: 'your-api-key',
    endpoint: 'your-endpoint',
  }

  await subscribe(config, subscriptionRequest, async (data) => {
    console.log(data);
  }, async (error) => {
    console.error(error);
  });
}

main().catch(console.error);