我试图将eth从一个地址发送到另一个地址,但我得到了一个错误:Error: Returned error: nonce too low,可能是什么问题?
const Web3 = require('web3')
const web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io'))
var Tx = require('ethereumjs-tx').Transaction;
var privateKey = Buffer.from('private_key', 'hex');
var rawTx = {
nonce: '0x000',
gasPrice: '0x09184e72a000',
gasLimit: '0x2710',
to: 'to_address',
value: '0x00',
}
var tx = new Tx(rawTx);
tx.sign(privateKey);
var serializedTx = tx.serialize();
web3.eth.sendSignedTransaction('0x' + serializedTx.toString('hex'))
.on('receipt', console.log);发布于 2019-12-04 09:30:50
Error: Returned error: nonce too lownonce基本上是指从特定帐户地址执行的事务数。为了修复上面的错误:
const accountNonce =
'0x' + (web3.eth.getTransactionCount(ethereum_account_address) + 1).toString(16)将rawTx中的nonce值替换为上面的值。
var rawTx = {
nonce: accountNonce,
gasPrice: '0x09184e72a000',
gasLimit: '0x2710',
to: 'to_address',
value: '0x00',
}这将消除现在太低的错误。
https://ethereum.stackexchange.com/questions/78044
复制相似问题