首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:现在太低

错误:现在太低
EN

Ethereum用户
提问于 2019-12-04 09:08:18
回答 1查看 22.5K关注 0票数 4

我试图将eth从一个地址发送到另一个地址,但我得到了一个错误:Error: Returned error: nonce too low,可能是什么问题?

代码语言:javascript
复制
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);
EN

回答 1

Ethereum用户

发布于 2019-12-04 09:30:50

代码语言:javascript
复制
Error: Returned error: nonce too low

nonce基本上是指从特定帐户地址执行的事务数。为了修复上面的错误:

代码语言:javascript
复制
const accountNonce =
  '0x' + (web3.eth.getTransactionCount(ethereum_account_address) + 1).toString(16)

将rawTx中的nonce值替换为上面的值。

代码语言:javascript
复制
var rawTx = {
  nonce: accountNonce,
  gasPrice: '0x09184e72a000',
  gasLimit: '0x2710',
  to: 'to_address',
  value: '0x00',
}

这将消除现在太低的错误。

票数 3
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/78044

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档