Recipe for Mining: Step 3

As mentioned before, every miner needs to find a nonce which makes the hash of the block header less than some target value.

This is how we implement Proof-of-Work in Bitcoin and every other Proof-of-Work cryptocurrency.

By finding the nonce, we have translated the energy burned in computation directly into voting power in the Proof-of-Work consensus protocol.

You may have noticed in this pseudocode that there are two different nonces, the header nonce and the coinbase nonce.

Keep in mind that the nonce in the header is a reasonably small number: only a 32 bit number.

This means that a powerful device can run through all the nonce possibilities within a second.

To make it such that we don’t reach a dead end with our mining puzzle, we need to change our puzzle if the header nonce has no viable options.

To do this, we change the coinbase nonce, a field within the coinbase transaction.

By changing this nonce, we change the Merkle Root, and therefore, we’re able to explore more options and hopefully find the answer to the mining puzzle.

Our mining puzzle is completely different.

We go through these loops until finally we find a valid nonce.

Recipe for Mining: Step 4