What Is a Coinbase Transaction and How Does It Work in Bitcoin?

What Is a Coinbase Transaction?
A coinbase transaction is the very first transaction in every Bitcoin block. This is how a miner receives the reward for that block. That reward is called the block reward and consists of two parts: newly issued bitcoin, the block subsidy, and the transaction fees from all the normal transactions the miner included in that block.
The miner who creates a candidate block always puts this transaction first in the block. Through the outputs, meaning where the money goes, the miner can send the reward to a personal address or to a mining pool.
Key Takeaways
- A coinbase transaction is always the first transaction in a Bitcoin block.
- Miners use this transaction to claim the block subsidy and transaction fees.
- Full nodes check whether the coinbase transaction follows the Bitcoin rules.
- A coinbase transaction has one special input that does not refer to a previous Bitcoin output.
- The reward can only be spent starting at block height h+100.
How Does a Coinbase Transaction Work?
A miner first creates a candidate block with the coinbase transaction at the top and then optionally adds transactions from the mempool. The mempool is basically the queue of transactions that have already been sent to the network, but are not yet in a block.
The miner then chooses where the reward goes. That can be a personal Bitcoin address, but in mining pools there is often a payout script that is set by the pool. The pool then handles how participants get paid.
The special coinbase input includes, among other things, the block height, meaning the block's sequence number. The miner can also add extra data there, such as an extra nonce. A nonce is a value that mining software keeps changing while searching for a valid hash.
Why is that useful? With proof of work, the miner tries many different hashes until one meets the Bitcoin rules. If the regular nonce in the block header is no longer enough to keep making new attempts, the miner can change the extra nonce in the coinbase transaction.
That changes the coinbase transaction ID. Then the merkle root also changes, which is a kind of summary cryptographic fingerprint of all the transactions in the block. That gives the miner many new chances to try hashes again.
The coinbase transaction only really counts once the miner finds a valid block and nodes accept that block. A node is a computer that checks the Bitcoin rules. If a node rejects the block, then the coinbase transaction is not part of the active Bitcoin blockchain either.
What Is the Difference Between a Coinbase Transaction and a Normal Transaction?
The big difference is that a normal Bitcoin transaction spends existing bitcoin, while a coinbase transaction records the block reward.
A normal transaction uses one or more inputs. Such an input refers to a previous, still “Unspent Transaction Output.” That unspent output is also called a UTXO. Simply put: a UTXO is a piece of bitcoin that is still waiting to be spent.
In a normal transaction, the value of the outputs must be equal to or lower than the value of the inputs. The difference is the transaction fee that the miner can receive.
A coinbase transaction works differently. It has exactly one special coinbase input. That input intentionally does not refer to an existing UTXO. Instead, it contains a zero hash as the previous transaction ID and the index 0xffffffff.
That does not mean the miner can just create bitcoin out of nowhere. The total value of the outputs may be at most equal to the subsidy for that block plus the fees from the other transactions in the same block.
There are also two simple block rules:
- A block must start with exactly one coinbase transaction.
- There may not be a second coinbase transaction later in the same block.
Another difference: the outputs of a coinbase transaction cannot be spent right away. There is a separate waiting period of 100 new blocks for that.
What Rules Apply to a Coinbase Transaction?
A coinbase transaction has to follow a number of fixed Bitcoin rules. If it does not, the entire block is rejected by the network.
The main rules are:
- The coinbase transaction is always the first transaction in a block.
- The transaction has one special input.
- That input does not refer to bitcoin received earlier, like in a normal transaction.
- The input includes, among other things, the block number, also called the block height.
- The miner cannot just give themselves any random amount of bitcoin.
- The total reward may consist of at most the block subsidy plus the transaction fees from the block.
The block subsidy is the amount of new bitcoin issued when a block is created. Bitcoin started with a reward of 50 BTC per block. After every 210,000 blocks, this reward is cut in half. That happens about once every four years and is called the Bitcoin halving. So miners cannot adjust this reward themselves.
If a block contains transactions with SegWit witness data, the coinbase transaction has another technical role. A so-called witness commitment is then included in the coinbase transaction. This cryptographically links the witness data of the transactions to the block, so nodes can verify this data.
Why Does a Coinbase Transaction Have No Normal Inputs?
A coinbase transaction does have an input, but not a normal input that spends bitcoin from a previous output.
That makes sense: the block subsidy is made available for the first time through this transaction. So there is no earlier UTXO for the miner to refer to. The transaction fees from the new block also go to the miner through this transaction.
You can think of it as the settlement for one block. The miner has produced a valid block and is therefore allowed to claim exactly the reward that belongs to that block. Full nodes then check whether that amount is correct.
Example: Suppose the block subsidy and all fees together form a certain maximum amount. If a miner puts more than that amount in the coinbase outputs, the block is invalid. The miner then gets nothing at all, not even the amount that was allowed.
The coinbase input also has a practical function during mining. The required block height and any extra nonce help mining software keep making new proof-of-work attempts.
How Long Does It Take for a Coinbase Transaction to Be Confirmed?
A coinbase transaction gets its first confirmation once the block it is in becomes part of the active Bitcoin blockchain.
How long that takes is not fixed in advance. The miner first has to find a valid proof-of-work block, and the network has to accept that block. Proof of work is the system where miners do computational work to find a hash that meets the Bitcoin rules.
The coinbase output is still not spendable right away after that. Bitcoin says it may only be used as an input starting at block height h+100, where h is the height of the block that contains the coinbase transaction.
For example, if the reward is in block 500, it can first be spent in block 600. So it is about 100 new blocks, not a fixed amount of time in hours or minutes. Blocks are not found at exactly the same moment every time.
Some crypto wallet apps count confirmations a little differently on screen. That is why this rule is the clearest one: a coinbase output from block h becomes spendable in block h+100.
Why Are Coinbase Transactions Important for Bitcoin?
Coinbase transactions are important because they determine how new bitcoin is issued according to the fixed Bitcoin rules and how miners receive their transaction fees.
The block reward gives miners a reason to put computing power into proof of work and create valid blocks. Without a coinbase transaction, there is no standard way to assign that reward within a block.
At the same time, Bitcoin keeps the money supply under control. Every full node checks for itself whether the coinbase transaction pays out too much. If a miner tries to claim extra bitcoin, nodes will not accept the block. So one miner cannot change the rules or create extra bitcoin on their own.
This transaction is also useful for mining itself. By changing data such as an extra nonce, the merkle root changes and the miner gets more hashes to try.
With SegWit, the coinbase transaction also plays a role in recording witness data. That way, this additional transaction data is cryptographically tied to the block.
What Risks and Limitations Do Coinbase Transactions Have?
The biggest limitation is that the received bitcoin is not available right away. A miner or mining pool has to wait until 100 new blocks have been added before the coinbase output can be spent. That temporarily limits liquidity.
Also, the reward is only valid as long as the block is part of the active Bitcoin blockchain. If a block is not accepted, or later falls out of the active chain because of a chain reorganization, then the related output cannot be spent.
A miner also has to be very precise with the amount. Claiming too much makes the entire block invalid. Claiming less is allowed, as long as the upper limit is not exceeded, but then the miner misses out on part of the possible income.
The coinbase scriptSig has limited space. It can be at most 100 bytes and must start with the block height. That leaves little room for free text or other metadata.
Anything a miner puts in there becomes publicly visible once the block is included. A mining pool, for example, can add a recognizable tag. That can reveal information about who produced the block.
Finally, this reward still depends on a proper spending script and the right keys. If the script is set up incorrectly or the needed keys are no longer available, the reward can remain unspendable despite the 100-block rule.
Conclusion
A coinbase transaction is the special first transaction of every Bitcoin block. It lets the miner receive at most the block subsidy and the transaction fees from that block.
The transaction looks like a normal Bitcoin transaction, but it has one special input that does not refer to earlier bitcoin. That is necessary because the block subsidy becomes available for the first time through this route. At the same time, nodes strictly enforce how much the miner may claim.
As a regular Bitcoin user, you usually do not see a coinbase transaction directly. But under the hood, it is an important part of Bitcoin: it connects mining, proof of work, the issuance of new bitcoin, and transaction fees.