Get started
Get started
Have you ever wondered how bitcoins are created? Of course, they are generated by the mining process, but their issuance is mostly based on the Coinbase transaction. This specific transaction, which is essential to the functioning of Bitcoin, has become more complex as the protocol evolves. In this article, I invite you to discover in detail everything you need to know about this Coinbase transaction.
The coinbase transaction is always the first transaction in every Bitcoin block. It is generated by the miner who successfully produced a valid proof of work for this block.
This transaction plays a role on two levels. On the one hand, it allows the winning miner to be rewarded by awarding him the bitcoins that are due to him. On the other hand, it is used to introduce new bitcoins into the money supply in circulation.
The bitcoins received constitute what is called the block reward. It's an economic incentive for miners to invest in the Bitcoin proof-of-work process. This reward consists first of all of the fees accrued on transactions integrated into the block. In fact, each time you make a Bitcoin transaction and it is confirmed, the fees you chose when creating it are recovered by the miner who produced the block.
The block reward also consists of an amount of newly created bitcoins. This is called block funding. This grant is governed by the rules of the protocol. Initially set at 50 bitcoins per block in 2009, it is halved every 210,000 blocks, or approximately every four years, during an event known as a “halving.” Since the last halving in 2024, the grant awarded for each block is 3.125 BTC.
So, all the BTC in circulation on Bitcoin initially came from a Coinbase transaction.
Coinbase is a very specific transaction. Unlike other Bitcoin transactions, it must meet certain specific criteria to be considered valid. The first of these criteria is that it must include a single input, which, unlike the usual inputs, must not reference any existing UTXO. As mentioned earlier, the Coinbase transaction is used to generate new bitcoins. This means that, for new UTXOs created at the output of this transaction, no input UTXOs should be consumed. Bitcoins are created ex nihilo. This is why it is sometimes said, to simplify, that the coinbase has no input. In a traditional transaction, this would be impossible, as it is necessary to provide bitcoins as input to cover the amount you want to transfer.
In reality, there is indeed an input in the coinbase. To ensure that this input does not spend any bitcoin, it is mandatory that the coinbase transaction uses a non-existent UTXO, designated by the following value:
0000000000000000000000000000000000000000000000000000000000000000000000000000ffffffff
Usually, each input in a Bitcoin transaction is accompanied by a scriptSig containing the digital signature needed to unlock the UTXO used. However, in the case of the coinbase transaction, since no real UTXO is consumed, there is no need to include a scriptSig. Instead, an empty field is used, which may contain arbitrary data chosen by the minor. This field is commonly referred to as the “Coinbase Field.”
It is precisely in this field that Satoshi Nakamoto inserted the famous sentence” The Times 03/Jan/2009 Chancellor on Brink of Second Bailout for Banks ” in the very first block of the Bitcoin blockchain (the Genesis block).
Since the adoption of BIP34 in 2012, the only constraint imposed on miners for the coinbase field is to include the height of the block being mined at the beginning. This added precision helps to clarify how the network accepts block structure changes and consensus rules, while ensuring the uniqueness of each block and each Coinbase transaction.
The rest of this field is completely free. Currently, minors use it for several functions. First, under mining pools, a unique identifier for each individual chopper is included to ensure that pool participants do not duplicate their work unnecessarily. By each having a slightly different coinbase field, this ensures that no two hashers will ever do the exact same calculation.
Then, it is common to see the name of the mining pool that extracted the block entered in this field. While this practice is not mandatory, it is widely used among pools that choose to add their name to Coinbase transactions. However, this identification is not necessarily accurate, as there is nothing to prevent indicating the name of a specific pool without actually mining for it.
Finally, the rest of this field is often used as an informal extra-nonce. To generate a valid block, miners change the 32-bit nonce in the block header, creating multiple hashes until they find one that is less than or equal to the difficulty target. When all possible values of the nonce in the header have been exhausted, they use some of the free field of input in the coinbase transaction as an additional nonce to continue testing new hashes.
➤ Learn more about the structure of Bitcoin blocks.
In terms of the outputs of the Coinbase transaction, the structure is once again different from that of a normal transaction.
First, there are usually one or more outputs that distribute the mining reward, combining the fees and the block grant. These outputs, as in a classic transaction, consist of UTXOs locked by a scriptPubKey. The only constraint for miners is that the sum claimed does not exceed the total fees of all transactions included in addition to the block grant.
However, unlike traditional transactions, the bitcoins generated in a Coinbase transaction are subject to a maturity period of 100 blocks. This means that after mining the block, the bitcoins earned are not expendable until the end of this 100-block period. This rule aims to prevent the complications that could occur if the bitcoins came from a blockchain that would later become obsolete, as validated blocks are sometimes finally discarded in favor of other blocks of the same height, but integrated into a chain that has accumulated more work. If the newly created bitcoins were available immediately, any transactions that included them could be cancelled later, causing losses for the holders.
By imposing a period of 100 blocks before newly created bitcoins can be spent, we prevent the disturbances caused by coins from blocks that are later invalidated, by preventing them from circulating on the system and affecting other users. The probability of a chain reorganization occurring after 101 blocks is so low that it is considered zero.
In addition to the outputs that distribute the reward, there will also be other technical outputs in the coinbase. Since the SegWit soft fork in 2017, Coinbase transactions must also include an output with an OP_RETURN that contains the Merkle root of transaction witnesses.
This mechanism, designed to solve the problem of transaction malleability, separates signature data from the rest of the transaction. In a block, this signature data is grouped into a Merkle tree separate from that of the main transaction data, and the root of this tree is inserted into a Coinbase transaction output to ensure that it is integrated into the block.
The rest of the outputs of the Coinbase transaction remain free. It is not uncommon to see several OP_RETURNS in a coinbase. In addition to the root of the transaction witnesses, which is mandatory in the presence of SegWit transactions in the block, the other OP_RETURNS may contain arbitrary data used by miners for various specific purposes, such as merged mining, which allows Bitcoin proof-of-work to be reused on other blockchains, typically sidechains.
➤ Discover how Bitcoin sidechains work.
Coinbase transactions therefore play an essential role on Bitcoin. They serve not only to reward miners, to encourage them to contribute to the search for proof of work, but also to issue money in a fair, meritocratic and programmed manner, in accordance with the rules of the protocol.
Coinbase transactions are different from other Bitcoin transactions because they have a unique input that does not consume any existing UTXO. In other words, the bitcoins generated by a Coinbase transaction are free of any previous history.
Over time, the use of the Coinbase transaction has evolved. Since the implementation of SegWit, it now includes the Merkle root of transaction witnesses. For mining, these free fields are exploited by the pools for various internal needs.