5

This question already has an answer here:

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 transactionsproperty.

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.

marked as duplicate by Richard Horrocks, Nicolas Massart, Rob Hitchens - B9lab, Badr Bellaj, niksmac Mar 16 '17 at 9:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    I want to know how to find the latest transactions in an efficient way, without using a for loop that takes ages to complete. – Nickkerd Mar 15 '17 at 13:27
  • I posted an answer that shows how to use BatchRequest to reduce the amount of network requests – vilsbole Dec 6 '18 at 14:07
2

UPDATE:

I found this example on Github, someone found a way to scan blocks for transactions asynchronously! If you have a decent CPU, you can hit 300 blocks/second. It is very well documented as well.

Not the answer you're looking for? Browse other questions tagged or ask your own question.