TriportRPC

logsSubscribe

Subscribes to transaction log messages, streaming the logs of every transaction — or only those that mention a given account — as they are committed.

Solanasol.pubsubbasic+ — per-method tier gating on /ws/sol

logsSubscribe streams the log output of transactions as they execute. Each logsNotification delivers one transaction's worth of logs: the transaction signature, its err status (null on success), and the ordered logs array — the same Program ... invoke / Program log: ... lines you see in getTransaction metadata, but pushed to you in real time instead of fetched after the fact.

The first parameter is a filter. The string "all" subscribes to every non-vote transaction on the cluster; "allWithVotes" includes vote transactions too (a torrent — rarely what you want); and {"mentions": ["<pubkey>"]} narrows the stream to transactions that reference a specific account. The mentions array accepts exactly one pubkey per subscription — passing several is an error, so open one subscription per address you track. The optional config object takes a commitment level (processed, confirmed — the default — or finalized).

This is the workhorse method for event-driven indexing: watching a program id for every interaction with your protocol, detecting new SPL token mints by watching the token program, following a DEX pool address for swaps, or alerting on any transaction that touches a treasury wallet. Since program events on Solana are usually emitted as log lines, logsSubscribe on a program id is the closest native equivalent to an EVM event subscription.

Mind the failure modes. A mentions filter matches any reference to the account — including failed transactions, so check err before acting. Logs can be truncated when a transaction exceeds the node's log budget (Log truncated appears in the array). And like all Pub/Sub subscriptions, the stream dies with the WebSocket session: on reconnect you must resubscribe and backfill the gap with getSignaturesForAddress if you cannot afford to miss events. Stop the stream with logsUnsubscribe.

Parameters

Positional params array: [filter, config?].

filterstring | objectrequired
"all", "allWithVotes", or {"mentions": ["<base-58 pubkey>"]} (exactly one pubkey).
configobjectoptional
Optional configuration object (see below).
commitmentstringoptional
processed, confirmed (default), or finalized.

Response

Subscribe ack:

Each matching transaction is pushed as a logsNotification:

{
  "jsonrpc": "2.0",
  "method": "logsNotification",
  "params": {
    "subscription": 41902,
    "result": {
      "context": { "slot": 348392060 },
      "value": {
        "signature": "5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW",
        "err": null,
        "logs": [
          "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]",
          "Program log: Instruction: Transfer",
          "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success"
        ]
      }
    }
  }
}
result (on ack)integer
Subscription id — pass it to logsUnsubscribe.
params.result.context.slotinteger
Slot the transaction was committed in.
params.result.value.signaturestring
The transaction's first signature (base-58).
params.result.value.errobject | null
null on success, otherwise the TransactionError.
params.result.value.logsarray of string
Ordered program log lines emitted during execution.

Errors

CodeMeaningWhen it happens
-32602Invalid paramsMalformed filter — e.g. more than one pubkey in mentions.
4003forbiddenYour tier is below basic (tier_insufficient; the frame carries required_tier).
4029rate_limitedSubscribe rate exceeded for your tier.

Notes

  • One pubkey per mentions filter — open multiple subscriptions on the same socket to track multiple addresses.
  • Failed transactions match too: always branch on value.err.
  • Gaps on reconnect: the stream has no replay; backfill with getSignaturesForAddress + getTransaction after resubscribing.
  • Related methods: logsUnsubscribe, programSubscribe (account-state view of the same activity), and signatureSubscribe (status of one known transaction).