0

I'm trying to deploy a very simply ERC20 token contract using Truffle and Infura and getting this:

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x701cc16d9719131ba94533bde8b88eae6b80a090193e6cfcc08c4f1c29e65aa1
  Migrations: 0x3c0cc05bdb1f1e82db23cb0d0bf0f5e3666ff410
Saving successful migration to network...
  ... 0x07d4c68bf6e3453d9daa5f61757d14d9d24d79a8565671adc625fc742bf9d7ba
Saving artifacts...
Running migration: 2_deploy_contracts.js
Saving successful migration to network...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
nonce too low

After reading some other posts, I tried to "postpone" the 2nd migration so to let all infura nodes sync and be aware they need to promote my nonce by 1, this is how the main part of 2_deploy_contracts.js looks:

setTimeout(function(){
    deployer.deploy(MyToken, 'MyTokenName', 'MyTokenSymbol', initialSupply)
  },1000 * 60 * 15)

As you can see, I'm trying to give it 15 minutes to sync.

However, I still get the nonce too low, and I get it quite immediately. I suspect the 2nd transaction that get's a lower nonce isn't the deployment of my Token, rather something to do with Truffle's Migration contract, related to Saving successful migration to network...

Anyway, wether it is my bad, or Truffle's bad, how do I deploy to mainnet using truffle + infura without the nonce too low issue?

  • instead of relying on setTimeout, do take a look at the deployer.deploy().then() or async / await since you need to make the code wait for tx receipts, and only after they arrive send the next. – Micky Socaci Aug 12 '18 at 17:40
1

This is a public node problem. They take the transactions to their pool, but they do not increase the nonce counter for a long time. As a result, the following transactions go with the error "Nonce to low"

The solution here is to use your private node.

Although, there is one more workaround: Truffle + Infura on Mainnet: Nonce too low error

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