logsSubscribe

Subscribe to transaction logging

Parameters

filter (string | object, required)

Filter criteria for the logs to receive results by account type.

String Options:

  • all: Subscribe to all transactions except for simple vote transactions.

  • allWithVotes: Subscribe to all transactions, including simple vote transactions.

Object Options:

An object with the following field:

  • mentions (array of strings): Array containing a single Pubkey (base-58 encoded string). Subscribes only to transactions mentioning this address.

Note: The mentions field supports only one Pubkey string per method call. Providing additional addresses will result in an error.


object (optional)

Configuration object containing the following field:

  • commitment (string, optional): Specifies the desired level of commitment.


Result

Returns an <integer> representing the subscription ID. This ID is required for unsubscribing.


Code Sample

Request Example 1 (Filter by mentions with optional configuration):

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "logsSubscribe",
  "params": [
    {
      "mentions": ["11111111111111111111111111111111"]
    },
    {
      "commitment": "finalized"
    }
  ]
}

Request Example 2 (Subscribe to all transactions):

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "logsSubscribe",
  "params": ["all"]
}

Response Example:

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

Notification Format

The notification is an RpcResponse JSON object with the following fields in value:

  • signature (string): The transaction signature, base58 encoded.

  • err (object | null): Error if the transaction failed; null if the transaction succeeded.

  • logs (array | null): Array of log messages output by the transaction instructions during execution. If simulation failed before the transaction could execute (e.g., due to an invalid blockhash or signature verification failure), this will be null.


Example Notification

{
  "jsonrpc": "2.0",
  "method": "logsNotification",
  "params": {
    "result": {
      "context": {
        "slot": 5208469
      },
      "value": {
        "signature": "5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv",
        "err": null,
        "logs": [
          "SBF program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success"
        ]
      }
    },
    "subscription": 24040
  }
}

Last updated