TX Stream API

The NextBlock TX Stream API provides real-time streaming of Solana transactions filtered by program IDs. This independent service allows trading bots to subscribe to transaction streams and receive fast notifications for transactions involving specific programs, enabling quick detection of new DEX launches and trading opportunities.

To be authenticated to use NextStream, you have to send SOL to nextstream.sol. 5 SOL = 31 days of access. You can also send less to test the service for a few days. The minimum amount is 1 day (0.17 SOL). Upon sending SOL to nextstream.sol, the address from which you sent the SOL becomes authenticated for one concurrent connection per region. You have to use the SOL sender wallet to authenticate to the NextStream server.

Examples in Rust, TypeScript and Golang are available at github.com/nextblock-ag/nextblock-stream-examples

Overview

To subscribe to NextStream:

  1. Build an authentication message: {domain}|{publickey}|{nonce}|{timestamp}

  • domain: the host you are connecting to (e.g. fra.stream.nextblock.io:22221)

  • publickey: the Solana public key of the account that sent the fee transaction

  • nonce: random integer

  • timestamp: current unix time (seconds)

  1. Sign the message with the corresponding Solana private key.

  2. Send a subscription request (NextStreamSubscription) with:

  • AuthenticationPublickey

  • AuthenticationMessage

  • AuthenticationSignature (base58)

  • List of accounts you want to filter for

  1. Receive streamed messages, each containing a Packet with:

  • transaction (binary-encoded Solana transaction)

  • slot

Proto Specification

syntax = "proto3";

package stream;

option go_package = "nextblock-stream-examples/golang-example/protos";

message NextPacket {
    bytes transaction = 1;                  // raw transaction bytes
    uint64 slot = 2;
}

message NextStreamSubscription {
    string authentication_publickey = 1;    // the publickey you used to send 5 SOL to nextstream.sol
    string authentication_message = 2;      // the finished authentication_message:
    string authentication_signature = 3;    // base58 signature, signed_message signed by authenticated_publieky

    repeated string accounts = 4;           // base58 accounts to subscribe to
}

message NextStreamNotification {
    NextPacket packet = 1;
}

service NextStreamService {
    rpc SubscribeNextStream (NextStreamSubscription) returns (stream NextStreamNotification) {}
}

Available Endpoints

Choose the endpoint closest to your location for optimal latency:

  • Frankfurt: fra.stream.nextblock.io:22221

  • Amsterdam: amsterdam.stream.nextblock.io:22221

  • London: london.stream.nextblock.io:22221

  • Singapore: singapore.stream.nextblock.io:22221

  • Tokyo: tokyo.stream.nextblock.io:22221

  • New York: ny.stream.nextblock.io:22221

  • Salt Lake City: slc.stream.nextblock.io:22221

Examples

Use Cases

  1. Trading Bots: Real-time transaction detection for automated trading strategies and sniping new DEX launches

Best Practices

  1. Choose optimal endpoint: Use the endpoint closest to your location

  2. Filter efficiently: Subscribe only to programs you need to reduce bandwidth

  3. Handle reconnections: Implement automatic reconnection logic

  4. Process quickly: Handle incoming transactions efficiently to avoid backlog

  5. Use connection pooling: For high-throughput applications

  6. Monitor connection health: Implement heartbeat/keepalive mechanisms

Last updated