# What is the difference between account nonce and block nonce?

Block and accounts both use a value called "nonce" but they seem to represent something very different.

• For account I understand that the nonce is an integer quantity indicating the number of transactions created by this account to prevent replay of transactions.

• For block, I understand that it's a 64-bit value that, combined with mix-hash, proves the computational work required to build the block was made.

If my understanding is right, do you have more info on how this block nonce is computed? And perhaps why it's called the same way as the account nonce even if they are not the same things?

• blockchain-basics.com/HashPuzzle.html the nonce of block is just the number that you need to be added to the block to get a hash with leading #x number of Zeros, that is simple way to explain proof of work, you cannot computed , the miners can just try random numbers until they find it Jun 20 '19 at 13:39
• In you example can I compare 'data' to mix-hash? Jun 20 '19 at 13:45
• yes the data in that example is a reference for the mix-hash Jun 20 '19 at 13:46
• Do you want to write an answer or I can write one from your hints? Jun 20 '19 at 14:13

First of all, in bitcoin and subsequently in every other blockchain `nonce` is shortcut for nonsense. It does not make any sense to the block data but it is there. Lets see why is it there?

A Block basically should have

1) Previous block hash, and

2) List of transactions to be mined in that block

With these values no matter how many times you calculate the block hash it will always be the same. And that hash might not be a valid hash. The only way to get different hash is by changing some data in the block.You cannot change `Previous hash` or `transaction data` but you can insert new transactions in your list or remove some of them or use different set of transactions. But, this is inefficient to do every time because the goal is to find a valid block hash faster than others. Inefficient because to insert a new transaction into that list you have to first verify the transaction.

Therefore, you introduce a random variable in the block whose sole purpose is to help generate a new block hash. This variable is called nonce. Now, the block structure changes to following:

1) Previous hash

2) List of Trasactions

3) Nonce

Now, you calculate block hash based on these data. If your hash is invalid again, you choose a different nonce and try again repeatedly unless you get a valid block hash.

You can clearly see `Nonce` can be any data randomly selected. It can be anything, number, string, bytes, anything but for simplicity you chose it to be a number with initial value 1. This ease you to quickly calculate a hash because now you do not have to take a random value but increase the nonce by 1 and hash the block again.

# Account Nonce

Conceptually it is same as block nonce. Block Nonce is used to differ the block hash, account nonce is used to differ the transaction hash. And since transaction count from an account is always in an increasing order (unique), lets use this value as Account Nonce.

• "nonce is shortcut for nonsense." - I've not heard that before. I think it's generally considered that the origin is either "number used once", or it's derived from the term "nonce word", which is "a lexeme created for a single occasion to solve an immediate problem of communication". Jun 20 '19 at 15:17
• I never heard about nonsense neither, and the used only once origin is the most advertised one : en.wiktionary.org/wiki/nonce Jun 20 '19 at 15:50
• @RichardHorrocks perhaps from here ? coincentral.com/what-is-a-nonce-proof-of-work -> see the title Jun 21 '19 at 12:17
• @biplavo I like your answer but it would need some fixes on typos and make it more concise, remove the "nonsense" thing and maybe give so examples. Jun 21 '19 at 12:25
• @NicolasMassart - It does make the title sound catchy :-) Jun 21 '19 at 13:01