I am trying to figure out the most efficient way to poll latest blocks.
I found that there is a newBlockHeaders
event that I can subscribe to using web3js.
What is not clear to me is how to track the number of confirmations?
The premise of the question is that I want to find an efficient way to get events for a large number of transactions. My thinking is that I need to:
- Observe and filter
pendingTransactions
- Observe
newBlockHeaders
- Use
getBlock
to identify all transactions in the block - Once I find
pendingTransactions
mentioned ingetBlock
, usegetTransactionReceipt
to find transaction logs.
The question is thus: Is newBlockHeaders
sufficient for my use case or is it possible that transactions included in block might not have receipt / might not go through?