Is there a way to get data similar to the ones provided by web3.eth.getBlock(blockNumber)
but with multiple blocks at once?
The goal is to get the timestamps for 100 blocks in a row without performing 100 http calls to Infura. Thank you.
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityTake a look the wiki with all possible calls https://github.com/ethereum/wiki/wiki/JSON-RPC
There are two ways get block:
But no way to get multiple blocks. You need to implement it by yourself.
You have batch requests if the client you are using support them.
var batch = web3.createBatch();
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback));
batch.add(web3.eth.contract(abi).at(address).balance.request(address, callback2));
batch.execute();
From the documentation:
Batch reqests are not faster! In fact making many requests at once will in some cases be faster, as requests are processed asynchronously. Batch requests are mainly useful to ensure the serial processing of requests.