0

I try to send eth from one address to another, but I get an error:Error: Returned error: nonce too low What could be the problem?

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);
1
  • Nonce should start with "1". And BTW, has it not occurred to you that the error nonce too low implies that you should try a higher nonce??? This question really depicts you as lazy and/or incompetent. In order to fix this impression, I honestly suggest that you do slightly more than posting a piece of code and an error alongside it. – goodvibration Dec 4 '19 at 9:11
1
Error: Returned error: nonce too low

A nonce is basically the number of transactions that have been performed from a particular account address. In order to fix the above error:

const accountNonce = '0x' + (web3.eth.getTransactionCount(ethereum_account_address) + 1).toString(16)

Replace the nonce value in the rawTx with the above one.

var rawTx = {
  nonce: accountNonce,
  gasPrice: '0x09184e72a000',
  gasLimit: '0x2710',
  to: 'to_address',
  value: '0x00',
}

This will get rid of the nonce too low error.

2
  • thank you! but now i get an error:Error: Provided address "1.2671193663220406e+48" is invalid, the capitalization checksum test failed, or its an indrect IBAN address which can't be converted. – Ayurpwnz Dec 4 '19 at 9:40
  • Enclose address in single quotation marks. to get rid of this. – balajipachai Dec 5 '19 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.