Home › Glossary › Coinbase transaction

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).

BIPs that define Coinbase transaction

  • BIP 34 (block height in coinbase): Block v2, Height in Coinbase: Deployed. Upgraded blocks to version 2 and required each block's coinbase transaction (the one paying the miner) to include the block's height. This makes every coinbase unique, preventing duplicate…
  • BIP 30: Duplicate transactions: Deployed. Added a rule forbidding a block from including a transaction with the same ID as an earlier one whose outputs are not fully spent. Such duplicates can overwrite earlier coins and make them…
  • BIP 141 (SegWit): Segregated Witness (Consensus layer): Deployed. Defines Segregated Witness (SegWit), which moves signatures into a separate "witness" section of each transaction while remaining compatible with older nodes. This fixed transaction malleability,…
  • BIP 42: A finite monetary supply for Bitcoin: Deployed. A tongue-in-cheek proposal fixing a software quirk that would have made the block reward reappear and coin issuance restart a couple of centuries from now. It ensures the roughly 21 million coin…
  • BIP 54: Consensus Cleanup: Complete. Bundles fixes for several long-standing protocol weaknesses: the timewarp attack (manipulating block timestamps to speed up coin issuance), blocks that take extremely long to validate, Merkle tree…
  • BIP 22: getblocktemplate - Fundamentals: Deployed. Defines getblocktemplate, a way for a node to give miners a full block template rather than just a header to hash. Miners can then see and optionally choose which transactions go into a block,…
  • BIP 145: getblocktemplate Updates for Segregated Witness: Deployed. Updates getblocktemplate, the interface miners and mining pools use to request a block to work on, so it supports SegWit. Without this, miners could not build blocks that include SegWit transactions…

Related terms

  • Merkle tree: A Merkle tree hashes many items into one 32-byte root, so any single item can be proven to be included with a short proof instead of the whole list.
  • OP_RETURN: OP_RETURN is the Bitcoin Script opcode (0x6a) that makes an output provably unspendable, used to embed small amounts of data in a transaction.
  • SegWit (Segregated Witness): SegWit (Segregated Witness) is the 2017 soft fork that moved signatures into a separate witness, fixing malleability and introducing block weight.
  • Satoshi (sat): A satoshi (sat) is the smallest unit of bitcoin: one hundred-millionth of a bitcoin, or 0.00000001 BTC. 1 BTC = 100,000,000 sats.