How can I display multiple blocks like (ten latest blocks) using infura api and web3js
If you want to immediately get the latest 10 blocks there is no method inherently in the JSON-RPC that does this. You would call eth_getBlockByNumber
with the latest
parameter. Once you receive that result, you would find the number
field and request additional blocks by working your way backwards and requesting the previous 9 blocks.
1 Like