我正在使用 web3js v1.0.0-beta.34在循环中将签名交易发送到 geth 节点Geth/v1.8.13-unstable-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>
这个问题的原因可能是什么?
测试.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)
})
}