voteSubscribe – Solana

The voteSubscribe RPC Solana method allows clients to subscribe to notifications whenever a new vote is observed in gossip.

Unstable Method

This subscription is unstable and only available if the validator was started with the --rpc-pubsub-enable-vote-subscription flag. The format of this subscription may change in future Solana updates.

Supported Networks

  • Mainnet

Parameters

None: This method does not require any parameters.

Result

Returns an integer representing the subscription ID, which is required for unsubscribing.

Result Format

  • integer: The subscription ID.

Request Example

API Endpoints

wss://go.getblock.io/<ACCESS-TOKEN>/

JSON-RPC Request

wscat -c "wss://go.getblock.io/<ACCESS-TOKEN>/" --exec '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "voteSubscribe"
}'

Response

A successful request returns a subscription ID.

Example Response

In this response:

  • result: 0 represents the assigned subscription ID.

Notification Format

Upon vote updates, clients receive notifications containing vote details.

Example Notification

Notification Fields

  • hash (string): The vote hash.

  • slots (array): The slots covered by the vote, represented as an array of u64 integers.

  • timestamp (i64|null): The timestamp of the vote. It may be null if unavailable.

  • signature (string): The signature of the transaction that contained this vote.

  • votePubkey (string): The public key of the vote account, encoded in base-58.

Error Handling

Common voteSubscribe error scenarios:

  • Network issues: Problems with the Solana JSON-RPC API endpoints.

  • Invalid WebSocket connection: Issues maintaining a stable connection.

  • Subscription failure: If the validator was not started with the required flag.

Example Error Response

Use Cases

The Solana voteSubscribe method is useful for:

  • Tracking real-time validator votes in the Solana network.

  • Monitoring voting behavior for governance and security purposes.

  • Analyzing vote distribution across slots.

  • Building dApps that require real-time voting updates.

  • Ensuring applications stay in sync with validator activities.

Code voteSubscribe Example – Web3 Integration

Integration with Web3

By integrating Web3 voteSubscribe into Solana's Core API, developers can:

  • Monitor validator votes in real-time.

  • Improve blockchain tracking systems.

  • Enhance dApps with live vote updates.

  • Ensure applications remain synchronized with validator activities.

  • Optimize governance tools by tracking consensus formation.

This method is a critical component of the Core API that enables efficient vote tracking, request handling, and transaction validation in Solana-based applications.

Last updated

Was this helpful?