I have an array with a bunch of events. I get the block number from these events but I also need the block.timestamp which isnt returned in the event object, its returned by getting the block. So I am looking to do something like this:

  const getTimestamps = async (events) => {
  const ethcallProvider = new Provider(provider);
  await ethcallProvider.init();

  const contractCalls = events.map((event) =>
  const results = await ethcallProvider.all(contractCalls);
  return results;

I have hundreds of events so It would be helpful to be able to use something like multicall to be able to run all the getBlock functions in a single call. Or if theres a multicall libary out there that can do this that would also work. Thanks!

1 Answer 1


You can use ethers.providers.JsonRpcBatchProvider, its JS API is equivalent to the JsonRpcProvider. It simply batches the requests, so that multiple requests are sent together in a single network request, instead of separate network requests otherwise. You can find the docs for it here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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