I am using web3js v1.0.0-beta.34 to send signed transactions to a geth node Geth/v1.8.13-unstable-2e0391ea/linux-amd64/go1.10.3 in a loop.
Problem: In the initial iterations of the loop, Node.js prints the transaction hash to console. But when the loop has been running for more than a handful of seconds, we start to get the error:
Error: Failed to check for transaction receipt: {} at Object._fireError (/Users/x/test/node_modules/web3-utils/src/index.js:56:17) at /Users/x/test/node_modules/web3-core-method/src/index.js:260:23 at <anonymous>
What can be the cause of this problem?
test.js
for (var i = nonce; i < nonce + 1000; i++) {
nounce = web3.utils.numberToHex(nonce)
receivingAddr = getRandomWalletAddress()
var rawTx = {
nonce: i,
gasPrice: gasPriceHex,
gasLimit: gasLimitHex,
to: receivingAddr,
value: txValue,
data: txData
}
var tx = new Tx(rawTx);
tx.sign(key);
var serializedTx = tx.serialize();
web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('receipt', (receipt) => {
console.log(receipt.transactionHash)
})
}