Get Tangem

What is a cryptographic nonce, why is this parameter useful for mining and how is its value calculated?

Blog_nonce.png

A nonce is a numeric value that can be found on blockchain networks using the PoW consensus algorithm. The number, which must fulfil certain criteria, is used by miners when creating network blocks.

There is a belief that nonce is an abbreviation for “number used once”, though it is more likely to derive from the Middle English “nonse”, meaning a single occasion or instance. The term also has a rather unfortunate connotation in British English.

The value of nonces in crypto mining

Blockchain mining based on the proof-of-work consensus algorithm involves network nodes solving mathematical problems in order to add new blocks to the chain.

If we “look inside” a block to see what it contains, we’ll find a block header and a list of transactions. The block header contains:

  • the hash of the previous block;
  • the Merkle root hash (hashed transactions);
  • a timestamp;
  • the mining difficulty (a target number that is regularly adjusted so that the hash value of the block header is equal to or below it);
  • the nonce.

In order to add a block, miners don’t just need to calculate its hash. They need to do so in such a way that the result meets the difficulty criterion determined by the network. Without this, blocks would be added too quickly (hash calculation is a fairly simple operation) and the network wouldn’t be able to reach consensus in time.

Avoiding this “excess speed” is where the nonce comes in. When receiving a block, the miner adds it to the hash and calculates the hash of the resulting “set”. If the result doesn’t match the value set by the difficulty target, the miner changes the nonce value and recalculates the hash.

This approach requires the network nodes to have quite a lot of computing power, as miners need to sort through literally billions of nonces in order to find the correct solution.

As soon as the correct nonce value is found, the required hash sum is obtained and the block is created. It is then shared with the network so that it can be checked by other miners and, if there are no errors, added to the blockchain. The miner who created the new block then receives a reward.