Coinbase Transaction Generation Transaction
A coinbase transaction is the first transaction in a block. Miners use it to collect the block reward, and any additional transaction fees.
It's like putting your details on a self-addressed envelope so you can collect prize winnings.
When a miner creates a candidate block, the very first space for a transaction is reserved for the coinbase transaction.
Raw Data (source)
TXIDis all zeros. (We're not referencing an existing transaction)
f's (the maximum hexadecimal value for this field). (Again, because we're not trying to refer to an existing output).
scriptSigcan actually contain any data you like.1,2 (Because we do not have to unlock anything).
Other than that, you just need to be sure that the sum of your
output values does not exceed the block reward + transaction fees you're collecting.
As of BIP 34 the
scriptSig must start with a push of the height of the block. This change was made to prevent coinbase transactions from having the same TXID.
In the transaction data above, the
03 gives us the number of bytes being pushed, so the next 3 bytes
ec5906 indicates the height of the block.
Messages in coinbase transactions.
Miners often use the
scriptSig for strings of text. You just have to decode them (from Hex to ASCII) to read them.
Here are some interesting ones:
|Coinbase Transaction||scriptSig (decoded)||Notes|
||BitFury/BIP100/||Miners typically include the name of their mining pool.|
||/HaoBTC/Sun Chun Yu: Zhuang Yuan, will you marry me?/||You can put any string of text in to it.|
||The Times 03/Jan/2009 Chancellor on brink of second bailout for banks||This is the first coinbase transaction, mined by Satoshi Nakamoto.|
A coinbase transaction must be 100 blocks deep before you can spend its outputs.
This is a safeguard to prevent outputs that originate from the coinbase transaction from becoming unspendable (in the event the mined block moves out of the active chain due to a fork).