Error: nonce too low

In response to OpenZeppelin Upgrades: Step by Step Tutorial for Truffle - #11

Great Tutorial, thank you so much! I could deploy and upgrade the contract, on Rinkeby, through the proxy and the state is still there. What is not working anymore is the mint function. I get this error:
Uncaught { code: -32000, message: 'nonce too low' }

I am a little puzzled, how to increase the noonce and why did it work before? I am terribly sorry for asking this, I guess it is really noobish. do you have any experience with this error?

2 Likes

It seems like you are trying to do some actions in testnet or mainnet, so how do you connect web3? By infura or alchemy or some other way? I think there is some delay when web3 tries to get the actual nonce, maybe you can wait for another two blocks between every transaction.

2 Likes

Yes you are right, I connected to Rinkeby using alchemy API. I am sorry, I did not include this info. I tried to wait for more blocks and also tried to send a higher nonce along with the transaction. I got rid of the error, but the transaction did not go through and kept pending for loooong until it failed. Hm… I am quite new to testing on testnets, so I guess I have things to learn.
I think though, it could be related to this:
I am sending the transaction through truffle console and then have to confirm the upgrade transaction in metamask through Gnosis Safe. So, can it be that by doing this, the nonce in the truffle console is “lagging behind” ? :thinking:
Anyway thanks for your reply. I try to keep this thread updated as soon as I have more results.

1 Like

I think the nonce should be continuous, so if you have two transactions with different nonce, such as, one is 10, the other one is 11, only when the transaction with the nonce 10 has been confirmed, the other one can be confirmed. Before you send your transaction, I think you can have a look at the nonce: web3.eth.getTransactionCount(address)

2 Likes

Correct, I did check with web3.eth.getTransaction(address). I did not continue TestNet Testing so far, as I took a step back and tested locally to fully understand everything.
Currently I am working on making other contracts upgrade - safe, following the guide on Writing Upgradeable Contracts.
One thing I am wondering at the moment is, does the Migrations.sol also have to be upgrade - safe => changing constructor to initializer() ?
Testing locally, everything worked fine without touching the migrations.sol, but could it cause troubles if it still has a constructor?
:thinking:

1 Like

I think you are testing with the Truffle, as for the Migrations.sol, it is a default contract, I think it is only used for users, who are the first time to work with Truffle, to understand the process: compile, migrate and test, it should not be used in a production environment.
But if you want to deploy and test this contract, yeah, I think it should be upgrade - safe

2 Likes

Thank you, that makes sense. :pray:

1 Like

I’m trying the transferfrom function in openzeppelin. I have increased the allowance from erc20 token to my smart contact. However when I try to transfer from erc20 token to smart contract I get the same code 32000 non top low error.

I’m testing on rinkeby from truffle console

So are there some pending transactions of your account?