DOes nonce increase when the transaction fail?

TX1 nonce=0 succeed

TX2 nonce=1 failed

TX3 nonce=?

What value of nonce will TX3 have? It will be appreciated if you explain the reason why.

1 Answer 1


TX3 nonce=?


A transaction is context-sensitive, so it can succeed or fail depending on what came before.


A transaction that has failed has definitely failed and its failure is recorded as a fact on the blockchain. If this were not the case, then the transaction (nonce: 1) would be "missing" - in an ambiguous state, having neither succeeded nor failed. That would be indistinguishable from a pending transaction that might succeed in the future.

What else?

As a side note, while there is no assurance of FIFO when different accounts send transactions, transactions from a single address are assured to mine/process in nonce order. So 3 will not be processed until 2 has succeeded or failed.

And what else?

Nonce is a client-side responsibility. There is no hard requirement that it increments every time although wallets tend to do that in the background. Given that transactions must be in nonce order, and given that a transaction can stall if the gasPrice is too low, it is possible to jam up a wallet that keeps sending higher nonces. A solution to this problem is to "cancel" the unmined transaction by sending another with the same nonce and a higher gas price. This replacement transaction can have the same parameters or cancel (the first) by way of a "do nothing" setup. "Do nothing" could be send 0 ether to itself with no data. That sort of cancellation is typically a manual process but it could be implemented in a UI if the coders wanted to.

And what else?

For the benefit of others who happen upon this, tracking the nonce is a client-side responsibility. Apps that blast out lots of transactions need to deal with stuck transactions and track where they are. There is no reliable way to check the chain or transaction pool and discover what the nonce should be. It's important to understand the subtle issues before sending thousands of transactions or you will get into the glue.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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