-->

Web3.js sendSignedTransaction给“错误:无法检查交易收据”(Web3.j

2019-09-28 07:15发布

我使用web3js V1.0.0-beta.34以签订的交易发送到GETH节点Geth的/ v1.8.13不稳定,2e0391ea / Linux的AMD64 / go1.10.3在一个循环。

问题:在循环的初始迭代中,Node.js的打印交易散列到控制台。 但是,当循环已经运行了超过少数几秒钟,我们开始得到错误:

 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> 

可能是什么这个问题的原因是什么?

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)
        })
}

Answer 1:

发生这种情况是因为web3.js无法得到的交易收据,你可以看到这里的代码: https://github.com/ethereum/web3.js/blob/1.0/packages/web3-core-method/src/index .js文件#L261

你可以简单地通过调用eth.getTransactionReceipt重现错误,找到发生了什么事。



文章来源: Web3.js sendSignedTransaction gives “Error: Failed to check for transaction receipt”