Skip to content

Instantly share code, notes, and snippets.

@egalano
Last active July 8, 2020 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egalano/0f00f93a059e9f6acaa26e489bf8a4d7 to your computer and use it in GitHub Desktop.
Save egalano/0f00f93a059e9f6acaa26e489bf8a4d7 to your computer and use it in GitHub Desktop.
Get all block receipts in parallel
const ethers = require('ethers');
const util = require('util')
util.inspect.defaultOptions.maxArrayLength = null;
const PROJECT_ID = 'xxxx'
let provider = new ethers.providers.InfuraProvider('mainnet', [PROJECT_ID]);
async function getAllReceipts() {
provider.on('block', (blockNumber) => {
provider.getBlock(blockNumber).then(async (block) => {
const receipts = await Promise.all(block.transactions.map((tx) => provider.getTransactionReceipt(tx)));
receipts.forEach(console.log)
console.log(receipts.length)
});
});
}
getAllReceipts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment