Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Contract deploy error: nonce too low #29

Closed
RobinJayaswal opened this issue May 5, 2018 · 9 comments
Closed

Contract deploy error: nonce too low #29

RobinJayaswal opened this issue May 5, 2018 · 9 comments

Comments

@RobinJayaswal
Copy link

RobinJayaswal commented May 5, 2018

Command+Errors:

$ truffle migrate --network live --reset
Using network 'live'.

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

Cannot find much about this online. Is there a way I can manually specify a higher nonce for migrate?

Info: Connecting to Infura Node, Truffle v4.1.7, Node v9.5.0

@RobinJayaswal
Copy link
Author

RobinJayaswal commented May 5, 2018

I tried running again (without reset). This time it got one step further then encountered same issue:

$ truffle migrate --network live
Using network 'live'.

Running migration: 2_deploy_contracts.js
  Deploying MyContract...
  ... 0x...
  MyContract: 0x...
Saving successful migration to network...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
nonce too low

@cgewecke
Copy link
Contributor

cgewecke commented May 16, 2018

Hi @RobinJayaswal, sorry for the delay responding. This issue is being tracked at truffle 763. It's caused by Infura running a load-balancer in front of their nodes and the transactions intermittently falling out of sync as a result.

Some options:

  • introduce programmatic delays between deployments.
  deployer.deploy(Registry)
    .then(() => Registry.deployed())
    .then(registry => new Promise(resolve => setTimeout(() => resolve(registry), 60000)))
    .then(registry => deployer.deploy(Store, registry.address))
  • deploy locally using a light node.

Closing as duplicate.

@j10sanders
Copy link

Hi, I also have this issue. @cgewecke, I don't understand your solution. Are you suggesting adding that code to the migration file?

@cgewecke
Copy link
Contributor

@j10sanders Yes - I'm suggesting that you create time delays between deployments. The idea is to wait for a few blocks to pass before attempting another transaction so that infura's architecture has time to sync everything up. I just sketched that code in - not sure it works / have not tried this strategy myself, sorry. If you try it could you report your findings back?

Tangentially, truffle has a bug with the latest version of the HDWalletProvider (0.0.5) that causes it to hang at the very end of a migration. You can ctrl-c out of the command and everything will be fine - should be fixed in a patch release scheduled for tomorrow.

@eepstein
Copy link

did HDWalletProvider get patched? npm shows 0.0.5 as the current release

@cgewecke
Copy link
Contributor

cgewecke commented Jul 10, 2018

@eepstein The problem is at Truffle - HDWalletProvider 0.0.5 opens interval polling using eth-block-tracker and truffle needs to close that on command exit.

Are you seeing migrations hang with Truffle v4.1.13? If so could you try making sure your HDWallet providers are wrapped in a function in truffle.js as shown in the docs here?

@eepstein
Copy link

eepstein commented Jul 10, 2018

I've just kept thing on 0.0.3 while waiting for the fixes. Things mostly work at this point.

(Thanks for the quick reply.)

@cgewecke
Copy link
Contributor

cgewecke commented Jul 10, 2018

Yes @eepstein 0.0.3 should be fine. The upgrade was triggered by security warnings from npm audit about sub-dependencies we felt we had to address because module is a wallet.

@jlindberg-oss
Copy link

jlindberg-oss commented Nov 29, 2018

@cgewecke the workaround in #29 (comment) didn't work work for me. I still got

Saving successful migration to network...
Error encountered, bailing. Network state unknown. Review successful transactions manually.
nonce too low

I think because this is internal to deployer.deploy so the setTimeout was not helping

For anyone else finding this issue and still stuck on it, this workaround in truffle.js worked for me: https://ethereum.stackexchange.com/questions/44349/truffle-infura-on-mainnet-nonce-too-low-error

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants