Nonce in Cryptocoin Mining

Nonce is a random value used in cryptography and as the name suggests, it is coined for one occasion only. In bitcoin, we add a random SHA256 nonce to the block message to generate a hash value that meets the requirement.

It is very easy to produce hash for any value

In bitcoin block, nonce is a 32 bit field value such that when concatenated with the block message, the hash of the block contains a number of zeros in the beginning. Lets see an example:

Bitcoin block number: 422555

Difficulty: 213,492,501,107.51

Nonce value: 3275095067

Hash of the block 422555

0000000000000000042174a0b4c0edba5702456b22e58a553af8619009fa46aa

There are 17 zeros in the above hash. When bitcoin started, the first block i.e block number 0, also called as genesis block, had a difficulty value 1 with 8 running zeros required in the hash.

Bitcoin block number: 0

Difficulty: 1

Nonce value: 2083236893

Hash of the block 0

000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f

There are 8 zeros in the above hash. Difficulty levels went on increasing from 1 to current level of

213,492,501,107.51 in order to ensure that the time taken between 2 blocks being created remain 10 minutes.

The miners keep on checking varying nonce to generate a hash with requisite numbers of running zeros. One who finds the hash with that conditions, gets to keep the reward bitcoins (12.5 BTC) and transaction fee.

To summarise, nonce is a number that is added to the block message in order to get a hash with requisite running zeros.