JSON RPC API -2

Subscription Websocket#

After connecting to the RPC PubSub websocket at ws://<ADDRESS>/:

  • Submit subscription requests to the websocket using the methods below

  • Multiple subscriptions may be active at once

  • Many subscriptions take the optional commitment parameter, defining how finalized a change should be to trigger a notification. For subscriptions, if commitment is unspecified, the default value is "finalized".

accountSubscribe#

Subscribe to an account to receive notifications when the lamports or data for a given account public key changes

Parameters:#

<string> - account Pubkey, as base-58 encoded string
(optional) <object> - Configuration object containing the following optional fields:
    (optional) commitment: <string> - Commitment
    encoding: <string> - encoding for Account data, either "base58" (slow), "base64", "base64+zstd" or "jsonParsed". "jsonParsed" encoding attempts to use program-specific state parsers to return more human-readable and explicit account state data. If "jsonParsed" is requested but a parser cannot be found, the field falls back to binary encoding, detectable when the data field is type <string>.

Results:#

<number> - Subscription id (needed to unsubscribe)

Example:#

Request:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "accountSubscribe",
  "params": [
    "CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12",
    {
      "encoding": "base64",
      "commitment": "finalized"
    }
  ]
}
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "accountSubscribe",
  "params": [
    "CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12",
    {
      "encoding": "jsonParsed"
    }
  ]
}

Result:

Notification Format:#

The notification format is the same as seen in the getAccountInfo RPC HTTP method.

Base58 encoding:

Parsed-JSON encoding:

accountUnsubscribe

Unsubscribe from account change notifications

Parameters:#

Results:#

Example:#

Request:

Result:

blockSubscribe - Unstable, disabled by default

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

Subscribe to receive notification anytime a new block is Confirmed or Finalized. Parameters:#

Results:#

Example:#

Request:

Result:

Notification Format:#

The notification will be an object with the following fields:

-slot: - The corresponding slot.

blockUnsubscribe#

Unsubscribe from block notifications

Parameters:#

Results:#

Example:#

Request:

Response:

logsSubscribe

Subscribe to transaction logging

Parameters:#

Results:#

Example:#

Request:

Result: { "jsonrpc": "2.0", "result": 24040, "id": 1 }

Notification Format:#

The notification will be an RpcResponse JSON object with value equal to:

Example:

logsUnsubscribe

Unsubscribe from transaction logging

Parameters:#

Results:#

Example:#

Request:

Result:

programSubscribe

Subscribe to a program to receive notifications when the lamports or data for a given account owned by the program changes

Parameters:#

Results:#

Example:#

Request:

Result:

Notification Format:#

The notification format is a single program account object as seen in the getProgramAccounts RPC HTTP method.

Base58 encoding:

Parsed-JSON encoding:

programUnsubscribe

Unsubscribe from program-owned account change notifications

Parameters:#

Results:#

Example:#

Request:

Result:

signatureSubscribe

Subscribe to a transaction signature to receive notification when the transaction is confirmed On signatureNotification, the subscription is automatically cancelled

Parameters:#

Results:#

Example:#

Request:

Result:

Notification Format:#

The notification will be an RpcResponse JSON object with value containing an object with:

Example:

signatureUnsubscribe

Unsubscribe from signature confirmation notification Parameters:#

Results:#

Example:#

Request:

Result:

slotSubscribe

Subscribe to receive notification anytime a slot is processed by the validator

Parameters:#

None

Results:#

Example:#

Request:

Result:

Notification Format:#

The notification will be an object with the following fields:

Example:

slotUnsubscribe

Unsubscribe from slot notifications

Parameters:#

Results:#

Example:#

Request:

Result:

slotsUpdatesSubscribe - Unstable

This subscription is unstable; the format of this subscription may change in the future and it may not always be supported

Subscribe to receive a notification from the validator on a variety of updates on every slot

Parameters:#

None

Results:#

Example:#

Request:

Result: { "jsonrpc": "2.0", "result": 0, "id": 1 }

Notification Format:#

The notification will be an object with the following fields:

slotsUpdatesUnsubscribe

Unsubscribe from slot-update notifications

Parameters:#

Results:#

Example:#

Request:

Result:

rootSubscribe

Subscribe to receive notification anytime a new root is set by the validator.

Parameters:#

None

Results:#

Example:#

Request:

Result:

Notification Format:#

The result is the latest root slot number.

rootUnsubscribe

Unsubscribe from root notifications

Parameters:#

Results:#

Example:#

Request:

Result:

voteSubscribe - Unstable, disabled by default

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 the future

Subscribe to receive notification anytime a new vote is observed in gossip. These votes are pre-consensus therefore there is no guarantee these votes will enter the ledger.

Parameters:#

None

Results:#

Example:#

Request:

Result:

Notification Format:#

The notification will be an object with the following fields:

voteUnsubscribe

Unsubscribe from vote notifications

Parameters:#

Results:#

Example:#

Request:

Response:

Last updated