Proof-of-Work: Coinbase Transaction

Proof-of-Work: Coinbase Transaction

You might be asking, where does the block reward to miners even go? Well, it goes in the coinbase transaction! Whenever a miner produces a block, they first make a coinbase transaction which is always the first transaction of the Merkle Tree.

This coinbase transaction grants miners a reward of some bitcoins which can be spent at some later date.

This is how new bitcoins are minted, or introduced, into the network.

Also, the Coinbase transaction has a separate nonce field that is used in our hash puzzle as well.

 [pseudo code] Here’s some mining pseudo code.

We loop infinitely until we find a valid block.

In each loop, we try a Coinbase nonce first, and then in an inner loop, exhaust all possible values for header nonces. then we increment the Coinbase nonce, and repeat this cycle.

The reason why we want to do this in this order: to exhaust all header nonces for each coinbase nonce, is that changing the Coinbase nonce changes the merkle root.

it would be more expensive to recalculate the merkle root each time on each iteration of the inner loop.

So, we optimize by trying nonces in such a way as to only have to calculate the merkle root in each iteration of the outermost loop.

Intro: Signatures and Authentication