无法检查交易收据

无法检查交易收据

本文介绍了Web3.js sendSignedTransaction给出“错误:无法检查交易收据".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用web3js v1.0.0-beta.34 将已签名的事务发送到geth节点 Geth/v1.8.13-unstable-2e0391ea/linux-amd64/go1.10.3 循环.

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.

问题::在循环的初始迭代中,Node.js将事务哈希打印到控制台.但是,当循环运行了几秒钟后,我们开始收到错误消息:

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

推荐答案

发生这种情况是因为web3.js无法获取交易收据,您可以在此处查看代码: https://github.com/ethereum/web3.js/blob/1.0/packages/web3-core-method/src/index.js#L261

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

您可以通过调用eth.getTransactionReceipt来简单地重现该错误并查找发生的情况.

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

这篇关于Web3.js sendSignedTransaction给出“错误:无法检查交易收据".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 14:06