TeachMeBitcoin

The Coinbase Transaction

From TeachMeBitcoin, the free encyclopedia ⏱️ 4 min read

The Coinbase Transaction and Block Rewards

Every transaction in Bitcoin is a transfer of energy. Normally, a transaction must reference a previous output (a UTXO) to prove that the coins being spent actually exist.

However, there is exactly one exception in every block: the Coinbase Transaction. It is the very first transaction in every single block, and it is where new bitcoins are born.


🐣 What is a Coinbase Transaction?

The Coinbase transaction is the mechanism through which the pre-programmed monetary supply is distributed to miners who successfully secure the network. It has several unique properties that set it apart from standard transactions:

1. No Parent Inputs

A standard transaction spends existing inputs. A coinbase transaction has no inputs to spend. In the codebase: * The Previous Transaction ID is set to 32 bytes of zeroes: 0000000000000000000000000000000000000000000000000000000000000000 * The Output Index is set to 0xffffffff.

2. The Coinbase Script / Data (100 Bytes)

Because there is no unlocking script required to spend a nonexistent UTXO, the input fieldβ€”known as the Coinbase Scriptβ€”can hold up to 100 bytes of arbitrary data. * This is where Satoshi Nakamoto wrote the famous "The Times 03/Jan/2009" headline in the Genesis Block. * BIP 34 Rule: Since 2012, consensus rules require that the block's current height (e.g., 840000) must be written as the first few bytes of this data field. This prevents miners from mining identical block headers with identical coinbase outputs, which would otherwise overwrite historical UTXOs. * Miners also use this space to write mining pool names or to include an extra-nonce to expand their hashing entropy.


πŸ’° How the Reward is Calculated

The total amount of bitcoin a miner is allowed to claim in the coinbase transaction is mathematically capped: $$\text{Max Coinbase Output} = \text{Block Subsidy} + \text{Sum of All Transaction Fees in the Block}$$

If a miner accidentally claims less than this amount, the remaining coins are permanently burned (this has happened several times in history). If a miner claims even one satoshi more than this limit, nodes reject the block as invalid.

    [ Block Subsidy ] ────┐
   (Halves every 4 yrs)   β”‚
                          β”œβ”€β”€β”€β–Ί [ Total Allowed Coinbase Output ] ───► Miner Address
    [ Transaction Fees ] β”€β”˜
   (Paid by block users)

The Halving Schedule Capped Supply

The block subsidy began at 50 BTC and halves every 210,000 blocks (approximately every 4 years). This decay defines the 21 million supply limit:


πŸ”’ The Coinbase Maturity Rule: 100-Block Lock

What happens if a miner receives a 3.125 BTC block reward, immediately spends those coins to buy a car from Bob, and then a few minutes later, their block is reorganized out of the blockchain due to a network fork?

If the block is erased, the coinbase transaction that created those coins is also erased. The coins Bob received would vanish into thin air, leaving him empty-handed.

To prevent this nightmare scenario, Bitcoin consensus enforces the Coinbase Maturity Rule: * Newly mined bitcoins cannot be spent or used as inputs in any other transaction until they are buried under at least 100 confirmations (approximately 16.6 hours). * Standard transactions are immediately spendable, but coinbase rewards must "mature" to ensure they are deeply cemented into the blockchain before entering circulating supply. This is a crucial game-theoretic safeguard protecting the integrity of the network.

β˜• Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!