Nonce

Intermediate
A nonce refers to a number or value that can only be used once. Nonces are often used on authentication protocols and cryptographic hash functions. In the context of blockchain technology, a nonce refers to a pseudo-random number that is utilized as a counter during the process of mining.
For instance, Bitcoin miners need to try and guess a valid nonce as they perform multiple attempts to calculate a block hash that meets certain requirements (i.e., that starts with a certain number of zeros). When competing to mine a new block, the first miner to find a nonce that results in a valid block hash is granted the right to add the next block into the blockchain - and is rewarded for doing so.

In other words, the process of mining consists of miners performing a myriad of hash functions with many different nonce values until a valid output is produced. If the hashing output of a miner falls below the predetermined threshold, the block is considered valid and is added to the blockchain. If the output is not valid, the miner keeps trying with different nonce values. When a new block is successfully mined and validated, the process starts over.

Within Bitcoin — and most Proof of Work systems — the nonce is just a random number that miners use to iterate the output of their hash calculations. Miners employ a trial and error approach, in which every calculation takes a new nonce value. They do so because the probability of accurately guessing a valid nonce is close to zero.

The average number of hashing attempts is automatically adjusted by the protocol to ensure that each new block is generated - on average - every 10 minutes. This process is known as difficulty adjustment and is what determines the mining threshold (i.e., how many zeros the block hash needs to start with to be considered valid). The difficulty in mining a new block is related to the amount of hashing power (hash rate) committed to a blockchain system. The more hashing power dedicated to the network, the higher the threshold will be, meaning that more computational power will be required to be a competitive and successful miner. In contrast, if miners decide to stop mining, the difficulty will be adjusted, and the threshold will drop, so less hashing power will be required to mine, but the protocol will make sure that the block generation follows a 10-minute schedule, regardless.