fbpx

Crypto in an Hour: Part 12 – Nonce

by | Dec 10, 2019

Alright. We’re almost done with understanding how mining works. There’s only one more piece: the nonce.

Remember, one of the fundamental aspects of the hash function is that when you run an input through the hash function, it always produces the same output. In order to achieve different outputs, the miner must change the input. Remember how the difficulty target discussed in the last lesson requires that the output changes by adding zeros at the beginning? Each piece of information in the input is important and needs to stay constant, so how do you produce a different output? The nonce is an additional set of variable information which can be modified to produce a hash that matches the difficulty target. Finding a nonce that produces enough zeros at the beginning of the block’s name is how miners find the answer to the puzzle.

Because even a slight variation in the information can produce radically different outcomes, the nonce can be anything. Searching for a nonce that will produce an output that matches the difficulty target is like trying to find a needle in a haystack. Normally, a miner takes the information for the block and adds 1. When the output doesn’t meet the difficulty target, the miner adds 2, and so on until the difficulty target is reached. Maybe a miner starts at the number 1,000,000 or another random number and goes from there. When it comes to the competitive nature of mining, the faster a miner can find the nonce, the better.

When a nonce is found, the miner declares to the network that they found a nonce which produces a hash which meets the difficulty target. The other nodes on the network run the hash with the proclaimed nonce to verify it. Once 51% of the network verifies the hash, the block is added to the chain and everyone moves on to working on the next block. In Bitcoin’s proof of work model, the miner who found the correct nonce is then rewarded with new bitcoins that have never been circulated before.

That’s it. That’s how mining works and transactions are added to the blockchain. The next step to learning crypto is understanding how you interact with your coins, where you keep them, and how to use them. We’ll address that in our next lesson – digital wallets. 

X