3

When creating raw transactions, do I have to increase the nonce always in increments of 1 or can I use any nonce as long as it has not been used before?

Are there any specific rules? Could I also go up and down, like transaction #5 gets nonce 17 and transaction #6 gets nonce 13?

Can I use any nonce as long as it is not previously been used?

1
  • Increase by one or your tx queue is filled, AFAIK but I am on the phone...there is an answer explaining this Commented Jul 7, 2016 at 9:27

1 Answer 1

4

No, the nonce needs to equal the number of transactions sent from the address; so that also means no jumping around.

The account state comprises the following four fields: nonce: A scalar value equal to the number of transactions sent from this address

(Section 4.1 of Yellow Paper)

3
  • 1
    Strictly monotonic increasing starting from 0.
    – murrekatt
    Commented Aug 5, 2016 at 7:39
  • On practice it seems that if you skip a number in nonces of your transactions they will never be taken from the mempool, waiting indefinitely for that skipped number. So, yeah, strictly monotonic increasing.
    – Klesun
    Commented Oct 18, 2022 at 21:32
  • @Klesun Yes. The transactions skipping a nonce are not valid transactions yet, so that's why no one will put them in a block, because doing so would make the block invalid, and no one would build on top of an invalid block. You probably see that once there's a transaction with the missing nonce, that transaction and others with subsequent nonce, could have a chance of all getting included into the same block.
    – eth
    Commented Oct 20, 2022 at 2:46

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.