TriportRPC

logsSubscribe

Last updated:

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

This method takes no parameters.

Returns

logsSubscribe return value
FieldType
resultobject

Examples

curl https://triport.io/sol \
  -X POST -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <api-key>' \
  -d '{"id":1,"method":"logsSubscribe","params":[],"jsonrpc":"2.0"}'
const res = await fetch("https://triport.io/sol", {
  method: "POST",
  headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
  body: JSON.stringify({
  "id": 1,
  "method": "logsSubscribe",
  "params": [],
  "jsonrpc": "2.0"
}),
});
const data = await res.json();
import requests
resp = requests.post(
    "https://triport.io/sol",
    headers={"Authorization": "Bearer <api-key>"},
    json={"id":1,"method":"logsSubscribe","params":[],"jsonrpc":"2.0"},
)
print(resp.json())

Usage

  1. Transport: WebSocket.
  2. Networks: mainnet, devnet, testnet.
  3. Credit cost: 1 per call.

FAQ

What does logsSubscribe do?
Subscribes to transaction log messages, streaming the logs of every transaction — or only those that mention a given account — as they are committed.
How many credits does logsSubscribe cost?
logsSubscribe costs 1 credit(s) per call on Triport by default.
Is logsSubscribe available over WebSocket?
Yes, logsSubscribe supports WebSocket.