Last active
July 8, 2020 16:16
-
-
Save egalano/0f00f93a059e9f6acaa26e489bf8a4d7 to your computer and use it in GitHub Desktop.
Get all block receipts in parallel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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