Hello everyone,
I seem to have run into an issue, where i get simple event responses on new blocks, and then i make a new call after that again.
After like 5-10 calls or so, it gives an ETIMEDOUT error , and i cant understand why.
Would appreciate all the help i could get.
This is the error it gives.
And here is my code:
const { ethers } = require(“ethers”);
let network = “mainnet”;
const provider = new ethers.providers.InfuraProvider(network, ‘24254d9e2dc5439a841745f0c5e03a31’);
provider.pollingInterval = 20000;
provider.on(‘block’, async (tx) => {
console.log(“New block tx in “+network+”'s networks”, tx)
let block = await provider.getBlockWithTransactions(tx)
let transactions = block.transactions;
//check each transaction in the block
transactions.forEach(transaction => {
//if transaction contains any of the array ones.
if(transaction.to == “0x704cEF323aa8ac769C52fb61d32Db0a788CD3018”) {
console.log(“We have the transaction”, transaction)
let txid = transaction.hash;
}
});
})
Best regards, Robo