Skip to main content

logsSubscribe

Subscribe to transaction logging

Common use cases
Real-time program execution monitoringSubscribe to specific program ID via mentions field to monitor smart contract execution and logs for debugging. Common in DeFi protocols, NFT minting, and custom program monitoring where immediate visibility into program behavior is critical.
Wallet activity trackingMonitor specific wallet address for incoming/outgoing transaction mentions to build alert systems for payment processing or custody solutions. Limited to ONE wallet per subscription—create multiple subscriptions for multiple wallets.
Transaction log debugging for developmentUse "all" filter during testing to see all transaction logs and identify program errors and execution flow issues. Pair with local validator or devnet for comprehensive debugging without filtering noise.
Building redundant event listenersConnect to multiple RPC providers with same logsSubscribe filter to prevent missed transactions under high network load. Critical for production systems requiring 100% event capture, as single nodes can drop events.
Program log analysis and metrics collectionSubscribe to logs, parse program-specific event data, and extract business metrics from on-chain activity. Feed into analytics pipelines for monitoring and alerting on smart contract usage patterns.

Parameters

subscriptionId (string | object, required)

filter criteria for the logs to receive results by account type. The following filters types are currently supported:

  • all - subscribe to all transactions except for simple vote transactions
  • allWithVotes - subscribe to all transactions, including simple vote transactions
  • An object with the following field:
  • mentions: [ <string> ] - array containing a single Pubkey (as base-58 encoded string); if present, subscribe to only transactions mentioning this address The mentions field currently only supports one Pubkey string per method call. Listing additional addresses will result in an error.

config (object, optional)

Configuration object containing the following fields:

Fields:

Request

wscat -c wss://solana-mainnet.api.syndica.io -x '{
"jsonrpc": "2.0",
"id": 1,
"method": "logsSubscribe",
"params": [
{
"mentions": ["11111111111111111111111111111111"]
},
{
"commitment": "finalized"
}
]
}'
Network Selection

Replace mainnet with devnet in the URL to query devnet instead.

Response

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

Response Fields

Return value: integer

Subscription id (needed to unsubscribe)

Notification Format

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

  • signature: <string> - The transaction signature base58 encoded.
  • err: <object|null> - Error if transaction failed, null if transaction succeeded. TransactionError definitions
  • logs: <array[string]> - Array of log messages the transaction instructions output during execution.

Example:

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

FAQ and Troubleshooting

Can I subscribe to multiple pubkeys in the mentions array?
No, only ONE pubkey supported per logsSubscribe call despite array syntax in documentation.
Attempting to pass multiple pubkeys returns error: "Invalid Request: Only 1 address supported". Solution: Create separate subscription for each pubkey you want to monitor. This is the #1 source of confusion from Stack Exchange research.
Why is my self-hosted node not returning any logs?
Ensure validator started with --full-rpc-api flag for WebSocket support.
Also verify node is fully synced and caught up with cluster. May need account indexing enabled for some subscription types. Check WebSocket endpoint is accessible (default port 8900 for ws://).
How do I monitor specific instruction types with logsSubscribe?
logsSubscribe only filters by account mentions, not instruction types.
Use two-step approach: Subscribe with program ID filter, then parse logs client-side for specific instruction patterns. For full instruction data, capture signature from logs then call getTransaction.
Why am I missing transactions with logsSubscribe?
WebSocket subscriptions can drop events under high load or network issues.
Single RPC node may skip transactions compared to getSignaturesForAddress polling. Best practice: Use redundant listeners across multiple RPC providers for critical applications. Consider fallback polling with getSignaturesForAddress for guaranteed event capture.
What's the difference between logsSubscribe and accountSubscribe?
logsSubscribe monitors transaction logs when specified account is MENTIONED in transaction (in account keys array).
accountSubscribe monitors actual account DATA changes (balance, state modifications). Use logsSubscribe for transaction-level events, accountSubscribe for account state changes.

logsUnsubscribe (WebSocket)
Cancel logs subscription and free server resources. Always call before closing WebSocket or when component unmounts to prevent memory leaks. Returns true on success.

accountSubscribe (WebSocket)
Monitor account data changes vs transaction mentions. Use accountSubscribe when you need to track balance or state modifications, not just transaction occurrences.

programSubscribe (WebSocket)
Subscribe to all accounts owned by program as alternative to logsSubscribe for program monitoring. Provides account state changes instead of transaction logs.

getTransaction
Fetch full transaction details including instruction data after receiving log notification. Common workflow: logsSubscribe for real-time signature capture, then getTransaction for complete transaction data with logs and accounts.

signatureSubscribe (WebSocket)
Monitor specific transaction confirmation status. Use when you have a signature and want notification when it confirms. logsSubscribe discovers new transactions, signatureSubscribe tracks known transactions.

External Resources