1

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)
        })
}
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
  • Assuming your values are correct (which haven't been posted), there's nothing structurally wrong with the code. It would help to have the values you're setting in `rawTx` (especially how you're generating `txData`). You said you're getting transaction hashes...what are the results? There is one really annoying problem with web3js in that since it usually takes so long for transactions to be mined, the library will give you timeout errors, even though everything is ok. This appears to be different though. – Adam Kipnis Jul 18 '18 at 23:13
  • I have a client that does almost this exact thing. It fires off a bunch of signed transactions in a loop. I can post a version of that as an answer, but I'm not sure if it'll solve this exact problem. – Adam Kipnis Jul 18 '18 at 23:14

1 Answers1

-1

This happened because web3.js couldn't get the transaction receipt, you can see the code here: https://github.com/ethereum/web3.js/blob/1.0/packages/web3-core-method/src/index.js#L261

You can simply reproduce the error by calling eth.getTransactionReceipt and find what happened.

Peter Lai
  • 279
  • 2
  • 4