
Nonce
A nonce is an arbitrary number that the network miners are trying to find. A correct nonce will – when hashed together with the block header, result in a number that meets the current network difficulty restrictions.
Nonce is an acronym and stands for “number only used once”. It is the number a miner in the network has to find. When found, the miner has successfully “solved” the block and will usually receive a reward in the form of cryptocurrency and fees from those transacting on the network.
Key takeaways
- Nonce stands for “number only used once”. It is the number that miners are racing each other to find. By finding it they receive the block reward and the transaction fees.
- When an arbitrary number is hashed together with the block header the hash function returns a hexadecimal string. This string is actually a number and has to meet the target hash requirements to be valid.
- A correct nonce is found when the nonce hashed together with the block header returns a hexadecimal string that is valid according to the agreed upon difficulty.
- A nonce is repeatedly guessed by miners with special hardware. 9-10 years ago it was profitable to do this on any home PC however, now it is no longer profitable to mine on your home PC.
In a proof of work blockchain network there are usually many miners trying to solve for a correct nonce. As the network grows the collective work of the miners will increase the network difficulty and thus it will become harder and harder to find a correct nonce. The rules concerning difficulty increase was agreed upon at network launch and is hard coded in every node that participates on the network.
Block time
Usually there is a block time that the network is trying to aim for. In Bitcoins case this is set to 10 minutes. Whenever the collective work of miners becomes too big, the blocks will be found quicker than the target time. Therefore the difficulty in the network adjusts periodically. The opposite is true when blocks are found too slow – then the difficulty eventually decreases instead. By adjusting the difficulty in the network the inflation rate will always be known in advance. Unlike traditional fiat currency and/or precious metals where the inflation can vary.
Target Hash
The block at block height #500 on the Bitcoin network has the block hash shown here below.
000000004ff664bfa7d217f6df64c1627089061429408e1da5ef903b8f3c77db
Look at the hash and notice all the leading zeros. The leading zeros are what actually is the difficulty. Lets compare it to a more recent block.
The most recent block mined at write time is at block height #666685 and has the hash below.
000000000000000000081594d7361cced8247d544a9c656faed242226935db59
Notice how many more leading zeros there are? The more the difficulty of the network increases the more leading zeros there will be. So basically we can sum this article up with. If the function SHA256(Nonce + block header) returns enough leading zeros then the lucky miner will cash in his reward and then the process starts all over again – trying to find the nonce for the next block.