Coinbase transaction
Also called: coinbase, coinbase tx, generation transaction, block reward transaction.
The coinbase transaction is the first transaction in every block, written by the miner to collect the block subsidy and fees; it has no real inputs.
The coinbase transaction is the first transaction in every Bitcoin block. The miner writes it to pay themselves the block reward: the newly created subsidy plus the fees from all the block's other transactions. It is the only way new bitcoin comes into existence. (The term predates, and is unrelated to, the company named Coinbase.)
What's in a coinbase transaction
- One input that spends nothing. Its outpoint is null (an all-zero txid and index 0xffffffff). The input's script, the coinbase field, holds 2 to 100 bytes of arbitrary data, which miners use for extra nonce space and tags. The genesis block's newspaper headline sits here.
- The block height. Since BIP 34 (block 227,931, March 2013) the coinbase field must start with the block height, which makes every coinbase unique. That followed BIP 30, which banned duplicate txids after two early coinbases were duplicated at blocks 91,842 and 91,880.
- Reward outputs, which can't exceed subsidy plus fees. The subsidy started at 50 BTC and halves every 210,000 blocks.
- A witness commitment. In blocks with SegWit transactions, an OP_RETURN output commits to the root of the witness Merkle tree (BIP 141).
Rules for spending it
Coinbase outputs can't be spent until 100 more blocks have been mined (coinbase maturity), in case the block is orphaned. BIP 42 fixed a bug that would eventually have restarted the subsidy, and BIP 54 proposes requiring the coinbase nLockTime to equal the block height minus 1, so duplicate coinbases can't occur even in the far future. Mining pools build the coinbase from block templates (BIP 22, BIP 145).