Solana infrastructure, included with every server. LEARN MORE>

OpenInfra.shopeninfra.sh

Subscribing

Connect with the current Yellowstone TypeScript client and pass the complete filter request to subscribe().

  1. Install the client

    npm install @triton-one/yellowstone-grpc
  2. Set the API key

    export OPENINFRA_API_KEY=sk_live_xxxxxxxxxxxx
  3. Connect and subscribe

    import Client, { CommitmentLevel } from "@triton-one/yellowstone-grpc"; const client = new Client(  "https://geyser.sol.openinfra.sh:443",  process.env.OPENINFRA_API_KEY!,  { "grpc.max_receive_message_length": 64 * 1024 * 1024 },); await client.connect(); const stream = await client.subscribe({  slots: { confirmed: { filterByCommitment: true } },  commitment: CommitmentLevel.CONFIRMED,  accounts: {},  transactions: {},  transactionsStatus: {},  blocks: {},  blocksMeta: {},  entry: {},  accountsDataSlice: [],}); stream.on("data", (update) => console.log(update));stream.on("error", (error) => console.error("stream error:", error));stream.on("end", () => console.log("stream ended"));

    A slot update proves the TLS connection, x-token authentication, protobuf decoding, and subscription request all succeeded.

Reconnection

  • Open a new client stream after an error or end event.
  • Use exponential backoff with jitter and a maximum delay.
  • Pass the same subscription request again after reconnecting.
  • Track the last processed slot so your application can detect gaps.