Your cart is currently empty!
Solana: General onLogs listener queries – Listen for “processed”, “confirmed” AND “completed”
Here is a draft article based on your request:
Solana: General ‘onLogs’ Listener Questions – Listening on ‘processed’, ‘confirmed’, and ‘finalized’
As a Solana developer, you are probably aware of the importance of efficient and reliable transaction processing. One way to achieve this is by using listeners in conjunction with transactions. A listener is a function that responds to specific events or messages after a transaction has been processed on the blockchain. In this article, we will explore some common questions related to Solana’s ‘onLogs’ listener.
What are ‘onLogs’ listeners?
onSolana, also known as ‘onLogs’, is an event system that allows developers to create custom listeners to respond to specific events after a transaction has been processed on the blockchain. These listeners can be used to inform other applications about the status of a transaction, such as whether it succeeded or failed.
Listening on ‘processed’
When listening for ‘processed’ events, you want to know that a transaction has completed and its result is available. In Solana, this event is emitted when the transaction has been fully processed and confirmed by the node.
However, if you use the ‘onProcessed’ listener, it will only be triggered once all processing steps have completed, which can cause unnecessary delays or retries. To minimize latency, consider listening for ‘confirmed’ events instead.
Listening on ‘confirmed’
When listening for ‘confirmed’ events, you want to know that the transaction has been successfully processed and its result is available. In Solana, this event is emitted when the transaction has been fully processed and confirmed by the node.
Using the “onConfirmed” listener can be a good option if you need to respond quickly after the transaction processing has started.
Listening on ‘finalized’
When listening for ‘finalized’ events, you want to know that the transaction has been fully processed and its result is available. In Solana, this event is emitted when all processing steps are complete, including signing, broadcasting, and confirming.
Using the “onFinalized” listener can be a good option if you need to respond quickly after the transaction processing has finished.
Additional considerations
Before choosing an event type, consider the following factors:
- Latency requirements: If an immediate response is critical, listen for ‘processed’ events.
- Event order: Listen for ‘confirmed’ or ‘finalized’ events first to ensure the correct order of events.
- Additional context: Consider including additional context with your transaction result to provide a more complete picture.
Conclusion
In conclusion, Solana’s event system makes it easy to create custom listeners to respond to specific events after a transaction is processed. By choosing the right event type and considering latency requirements, developers can build efficient and reliable transaction processing solutions on Solana.
If you are building a transaction solution for your application, be sure to explore the available event types and choose the best option for your use case.
Leave a Reply