Skip to content

Nonce

  • by
What Is A Nonce?

Table of Contents

What Is A Nonce?

A nonce, short for “number used once”, is a pseudo-random number used by miners to iterate the output of their block hash. Miners use a trial-and-error method in which each computation uses a different nonce value. Miners need to find a valid nonce that results in a block hash below the current mining difficulty (the hash begins with a predetermined number of zeros). The first miner to find a nonce that results in a valid block hash wins the right to add a block of transactions to the blockchain and receives the block reward.

The nonce is just a number that miners use to change the output of their calculations. Each time the nonce is changed, an entirely new hash is created. This means that miners systematically guess different nonces until they find one that results in a valid hash.

If their hash output falls below a certain threshold, (begins with a certain number of zeros), the block is considered valid and is added to the blockchain. If the hash output doesn’t have the necessary number of zeros, the miner keeps trying with different nonce values until they find a valid hash output. Whenever a miner finds a valid nonce, a block is successfully mined and the process starts all over.

In short, the process of mining consists of miners systematically guessing nonces until a valid hash output is discovered. This repetitive process of trying a nonce and checking the resulting hash is only possibly by trial and error. There are no shortcuts. When a miner finds a valid hash, they broadcast proof of their work to the Bitcoin nodes who verify that the math is valid and they win the block reward.

The number of hashing attempts is automatically adjusted every 2,106 blocks so that each new block is generated approximately every 10 minutes. This is called the difficulty adjustment and it determines how many zeros a block hash needs to start with in order to be considered valid.

The more cumulative hash power that is committed to mining Bitcoin by every miner in the world, the harder it becomes for any given miner to find a valid nonce. The threshold is adjusted based on how much computational power is being used. As more miners come online, the number of guesses needed to find a valid hash will increase. If some miners stop mining, the difficulty is lowered, so it will be easier to find a valid hash, but the protocol will make sure that the block generation follows a 10-minute schedule over time.