logsSubscribe – Solana
The logsSubscribe JSON-RPC method allows clients to subscribe to transaction logs on the Solana blockchain.
The logsSubscribe RPC Solana method provides notifications for transaction logs, filtered by account type.
Developers can track all transactions, vote transactions, or transactions mentioning specific accounts.
Supported Networks
Mainnet
Devnet
Parameters
Required Parameters
filter (string | object): Defines filter criteria for transaction logs.
string: One of the following:
all: All transactions excluding vote transactions.
allWithVotes: All transactions including vote transactions.
object: A JSON object with:
mentions: An array containing a single Pubkey (as a base-58 encoded string).
Note: Only one Pubkey is supported; multiple Pubkeys will cause an error.
Optional Parameters
object (optional): Configuration object containing:
commitment (string): Commitment level for transaction log subscription.
Result
The response returns a subscription ID.
Result Format
integer: The subscription ID.
Request Examples
API Endpoints
JSON-RPC Request – Subscribe to Logs by Mentioned Account
JSON-RPC Request – Subscribe to All Logs
Response
A successful request returns the subscription ID.
Example Response
In this response:
result: The subscription ID.
Notification Format
Notifications are sent as JSON-RPC responses containing transaction log details.
Example Notification
Error Handling
Common logsSubscribe error scenarios:
Invalid filter: Incorrect filter string or JSON object.
Unsupported Pubkey array: More than one Pubkey specified.
Network issues: Problems with the Solana JSON-RPC API endpoints.
Example Error Response
Use Cases
The Solana logsSubscribe method is essential for:
Monitoring smart contract activity.
Tracking transactions mentioning specific accounts.
Detecting errors during transaction execution.
Real-time event streaming.
Code logsSubscribe Example – Web3 Integration
Integration with Web3
Integrating Web3 logsSubscribe into Solana's Core API allows developers to:
Track real-time logs for transactions.
Monitor specific account activity.
Optimize dApp performance by analyzing logs.
Detect errors early during transaction execution.
Last updated