我使用Geth/v1.8.13-unstable-2e0391ea/linux-amd64/go1.10.3 v1.0.0-beta.34向循环中的geth节点web3js发送已签名的事务。
问题:在循环的初始迭代中,Node.js将事务哈希输出到控制台。但是,当循环运行超过几秒钟时,我们就开始得到错误:
错误:未能检查事务收据:{} at (/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 /Users/x/test/node_modules/web3-core-method/src/index.js:260:23 at
造成这个问题的原因是什么?
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)
})
}发布于 2018-07-20 09:05:57
这是因为web3.js无法获得事务收据,您可以在这里看到代码:https://github.com/ethereum/web3.js/blob/1.0/packages/web3-core-method/src/index.js#L261
您可以通过调用eth.getTransactionReceipt来简单地再现错误并查找所发生的事情。
https://stackoverflow.com/questions/51410883
复制相似问题