Is there any way in the Web3 Javascript API to retrieve the latest, let's say five, transactions that were done on the blockchain?
The only option I can think of, is by using web3.eth.getBlock(web3.eth.blockNumber, true)
in a for loop and subtracting the blockNumber till you find an object in the transactions
property.
However, this can take a very long time, because in our case, we have our blockchain on an Azure server and a lot of empty blocks are created by nodes.
EDIT: Not a duplicate of this. I want to know how to find the latest transactions in an efficient way, without using a for loop that takes ages to complete.