Coinbase Transaction Explained

0
882
Coinbase Transaction Explained

Coinbase Transaction Explained

Transactions that are executed on networks such as Bitcoin are batched together to form a block. These blocks are then included on the blockchain to form an immutable and tamper-resistant record of all transactions that are made on the network. Each block added to the blockchain must include one or more transactions, and the first transaction required in that block is called the coinbase transaction, which is also known as the generation transaction.

Coinbase transactions are always constructed by a miner and will contain a reward for efforts expended during the proof of work mining process. The total amount of reward that a miner will collect is the sum of the block reward and the transaction fees taken from all the transactions that have been included in the block. To create a coinbase transaction, the miner will calculate the total amount of transaction fees for transactions that are included in a block, which is calculated as the following:

Total fees = sum(inputs) – sum(outputs)

Blocks are not required to include any non-coinbase transactions, but miners will almost always include additional transactions in order to collect the fees that are attached to these transactions.

The miner will then calculate the block reward for the newly created block, which is calculated based on its block height. The height of a block is simply the number of blocks in the chain between it and the first block in blockchain. The very first block included in a blockchain is known as the genesis block, which has a block height of zero. With the Bitcoin protocol, the block reward started at 50 bitcoins per block and is then reduced by half every 210,000 blocks, which can otherwise be interpreted as being approximately every 4 years. There have thus far been two instances in which the Bitcoin block reward has been halved. The next Bitcoin halving event will occur sometime in 2020, which will see block rewards reduced from their current level of 12.5 bitcoins per block to 6.25 bitcoins per block.

As it is the miner that constructs the coinbase transaction, there was the possibility that a miner could simply reward themselves in excess of the correct block reward and total transaction fee. However, a miner that rewarded themselves incorrectly, would find that block being deemed invalid by other participants in the network. Thus, that block would not be included in the blockchain and that miner would not be able to recoup the financial costs taken on during the proof of work mining process.

Another important feature of a coinbase transaction is that bitcoins involved in the transaction cannot be spent until they have received at least 100 block confirmations. The rationale behind this is to prevent a miner from spending a block reward and transaction fees from a block that may later be regarded as being a stale block after a fork in the blockchain.

The Coinbase Data

Usually, transactions on networks such as Bitcoin consume an unspent transaction output (UTXO) to form an input as part of a transaction on the network. However, this is not the case for a coinbase transaction. Instead, a coinbase transaction possesses only one input, called the coinbase, which effectively creates bitcoins from nothing. Whilst the coinbase data forms the input of a coinbase transaction, the coinbase transaction has only one output, which is payable to a miner's cryptocurrency address. Thus, the output of the coinbase transaction is the value of the block reward and total transaction fees attached to transactions that have been included in the block.

The coinbase data provides for up to 100 bytes of data, and except for the first few bytes, the remainder of the coinbase data can be used by miners in any way they wish. In other words, the rest of the coinbase data can effectively be regarded as being arbitrary data. For example, on the Bitcoin blockchain, Satoshi Nakamoto famously included the following text in the coinbase data of the genesis block:

‘The Times 03/Jan/2009 Chancellor on brink of second bailout for banks'

Whilst the first few bytes of the coinbase data was initially arbitrary, this was changed with the adoption of BIP-34, which required that the height of the block be included in the first few bytes of the coinbase data.