Skip to main content

0.01 credits per call

blockSubscribe on Solana: Subscribes to receive notification when a new block is confirmed.

Endpoint

wss://rpc.goldrushdata.com/v1/solana-mainnet
blockSubscribe is a WebSocket subscription method. Authenticate with Authorization: Bearer <GOLDRUSH_API_KEY>. See authentication.

Parameters

NameTypeRequiredDescriptionExample
filterstring | objectyes"all" or {mentionsAccountOrProgram: <base-58 address>}."all"
configobjectno{commitment?, encoding?, transactionDetails?, showRewards?, maxSupportedTransactionVersion?}.{"commitment":"confirmed","encoding":"jsonParsed","maxSupportedTransactionVersion":0,"transactionDetails":"full","showRewards":true}

Returns

number: Subscription id (used with blockUnsubscribe). Notifications arrive as blockNotification messages.
0

Examples

# Connect (header auth works from Node/CLI clients):
wscat -c "wss://rpc.goldrushdata.com/v1/solana-mainnet" \
  -H "Authorization: Bearer $GOLDRUSH_API_KEY"

# Once connected, send:
{"jsonrpc":"2.0","id":1,"method":"blockSubscribe","params":["all", {"commitment":"confirmed","encoding":"jsonParsed","maxSupportedTransactionVersion":0,"transactionDetails":"full","showRewards":true}]}
import { createSolanaRpcSubscriptions } from "@solana/kit";

// Authenticate with the Authorization: Bearer header on the WS handshake.
// See /goldrush-json-rpc/authentication.
const rpcSubscriptions = createSolanaRpcSubscriptions("wss://rpc.goldrushdata.com/v1/solana-mainnet");

const abortController = new AbortController();
const notifications = await rpcSubscriptions
  .blockSubscribe("all", {"commitment":"confirmed","encoding":"jsonParsed","maxSupportedTransactionVersion":0,"transactionDetails":"full","showRewards":true})
  .subscribe({ abortSignal: abortController.signal });

for await (const notification of notifications) {
  console.log(notification);
}

Errors

Standard JSON-RPC errors: -32600 invalid request, -32601 method not found, -32602 invalid params.