logsSubscribe
Subscribe to transaction logging
Common use cases
| Real-time program execution monitoring | Subscribe 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 tracking | Monitor 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 development | Use "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 listeners | Connect 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 collection | Subscribe 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 transactionsallWithVotes- 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 Thementionsfield 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:
commitment(string): The commitment describes how finalized a block is at that point in time. See Configuring State Commitment.
Request
- wscat
- JavaScript
- Python
wscat -c wss://solana-mainnet.api.syndica.io -x '{
"jsonrpc": "2.0",
"id": 1,
"method": "logsSubscribe",
"params": [
{
"mentions": ["11111111111111111111111111111111"]
},
{
"commitment": "finalized"
}
]
}'
const ws = new WebSocket('wss://solana-mainnet.api.syndica.io');
ws.on('open', function open() {
ws.send(JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "logsSubscribe",
"params": [
{
"mentions": ["11111111111111111111111111111111"]
},
{
"commitment": "finalized"
}
]
}));
});
ws.on('message', function incoming(data) {
console.log(data);
});
import websocket
import json
ws = websocket.create_connection('wss://solana-mainnet.api.syndica.io')
ws.send(json.dumps({
"jsonrpc": "2.0",
"id": 1,
"method": "logsSubscribe",
"params": [
{
"mentions": ["11111111111111111111111111111111"]
},
{
"commitment": "finalized"
}
]
}))
result = ws.recv()
print(result)
ws.close()
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 definitionslogs: <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.
"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.
How do I monitor specific instruction types with logsSubscribe?
logsSubscribe only filters by account mentions, not instruction types.
Why am I missing transactions with logsSubscribe?
WebSocket subscriptions can drop events under high load or network issues.
What's the difference between logsSubscribe and accountSubscribe?
logsSubscribe monitors transaction logs when specified account is MENTIONED in transaction (in account keys array).
Related Methods
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.