Blockchain – How mining works : The Nonce

In order to keep the blockchain secure, data from previous blocks are encrypted or “hashed” into a series of numbers and letters. This is done by processing the block input through a function, which produces an output of a fixed length.

The function used to generate the hash is deterministic, meaning that it will produce the same result each time the same input is used; can generate a hashed input efficiently; makes determining the input difficult (leading to mining); and makes small changes to the input result in a very different hash.


The process of guessing the hash starts in the block header. It contains the block version number, a timestamp, the hash used in the previous block, the hash of the Merkle Root, the nonce, and the target hash. Successfully mining a block requires a miner to be the first to guess the nonce, which is a random string of numbers.

A nonce is a “number used once” (i.e. for a single transaction) that serves to modify the output of a function. In proof of work systems like blockchain, the nonce is used to make it more difficult to generate a valid hash for a given block. Miners must find a nonce value that, when plugged into the hashing algorithm, generates an output that meets certain requirements (a certain number of leading zeros).

A miner must guess a nonce, append it to the hash of the current header, rehash the value, and compare this to the target hash. If the resulting hash value meets the requirements, the miner has created a solution and is awarded the block.

Nonces are also used to order outgoing transactions. This is mainly used in Ethereum, where user account transactions all have a nonce attached that is one more than the previous confirmed transaction.