Each time a block is mined, BTC are created for the miner. This is the only way new BTC can be created and a substantial portion of the compensation miners receive for securing the network and processing transactions. In the chart below, you can see that transaction fees were around 1-3% of total revenue for miners over the last couple of years, leaving BTC block rewards to provide 97-99% of a miner’s income.
Image from
https://www.theblock.co/data/on-chain-metrics/bitcoin/bitcoin-share-of-transaction-fee-from-total-miner-revenue-monthly
GetBlockSubsidy()
Block rewards are controlled by Bitcoin Core code, which you can find here on Github. The bit of code we are interested in is this:
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
// Force block reward to zero when right shift is undefined.
if (halvings >= 64)
return 0;
CAmount nSubsidy = 50 * COIN;
// Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
nSubsidy >>= halvings;
return nSubsidy;
}
https://github.com/bitcoin/bitcoin/blob/5aa0c82ccd6ceb4a141686fc8658f679de75a787/src/validation.cpp
When a block is being mined, the `GetBlockSubsidy()` function is called and it accepts two parameters. The first parameter is `nHeight` which represents the height of the blockchain. You can also think of it as the current block number. The other parameter is `Consensus::Params& consensusParams`, which is a large object of configuration variables and can be found here. The only configuration variable that `GetBlockSubsidy()` cares about is `nSubsidyHalvingInterval`. The function returns the number of satoshis that a miner receives for mining that block. You can think of satoshis, or sats, as the penny of bitcoin. Sats are the smallest unit of bitcoin and there are 100 million of them to a bitcoin.
Line by Line
Because this function is so important, and so short, we are going to dig into it line by line.
int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
`int` means that the variable `halvings` is an integer, or whole number. `halvings` is equal to `nHeight`, total number of blocks, divided by the `nSubsidyHalvingInterval` attribute of the `consensusParams` object. nSubsidyHalvingInterval is set to 210000 in the code as a constant number, and the current block at time of writing is 786,301. When we divide 783,301 by 210,000, we get 3.7442. You round down when dealing with integers, so `halvings` is equal to 3.
// Force block reward to zero when right shift is undefined.
if (halvings >= 64)
return 0;
These few lines were added to the bitcoin code to solve an error that will not occur for 240 years. We will get to the error later, but the code is telling the function to short circuit and just return the number 0 as the number of sats that miners should receive for mining a block if the halving number, which is currently 3, is greater than or equal to 64.
CAmount nSubsidy = 50 * COIN;
You can think of `CAmount` as simliar to an integer, but it has some special powers and represents a number of sats. `nSubsidy` equal to 50 times ‘COIN’. ‘COIN’ is a constant in the bitcoin code that is equal to 100000000 and represents the number of sats in a bitcoin. By multiplying `COIN` by 50, we get the number of satoshis in 50 bitcoin. `nSubsidy` is equal to 50 bitcoin, or 5 billion satoshis.
// Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
nSubsidy >>= halvings;
This code cuts the `nSubsidy` number, which starts at 5 billion Sats, and cuts it in half for each halving that occurs. We are in the 3rd halving, so it went from 5bn to 2.5bn sats, then from 2.5bn to 1.25bn sats, then from 1.25bn to 625mm sats. Since there are 100mm sats in a bitcoin, each block currently mined rewards the miner with 6.25 bitcoin. The function used to halve the nSubsidy number is called a right bitshift. Instead of iterating over the number of `halvings` and dividing `nSubsidy` by 2, a more efficient form of computation is used that takes advantage of how binary numbers are represented. The binary numbers are 64 bits, which means there are 64 digits that can be either 1 or 0.
This is what 5bn looks like in binary, plus 31 0’s in front to fill the 64 bits:
1 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0
This is what 2.5bn looks like:
1 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0
This is what 1.25bn looks like:
1 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 1 0 0 0 0 0 0 0
And this is what 625mm looks like:
1 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 1 1 1 1 1 0 0 1 0 0 0 0 0 0
You may notice that each of those number are the same except they have been shifted one place to the right, which drops a digit and makes the number shorter. This feature of binary representation makes for a really fast way of halving a number. `nSubsidy >>= halvings`
is saying that nSubsidy is now equal to `nSubsidy` (5bn) shifted to the right as many times as there have been `halvings` (3). Chop off the last 3 digits of the binary representation of 5bn via the right bit shift, and you get the binary representation of 625mm. Because integers always round down to a whole number, we stop creating bitcoin at the 33rd halving. Halving 33 will occur at block 6,930,000 and occur around 2140, 117 years from now. At that point, the 1 sat block reward from halving 32 will be cut in half and rounded down to 0. No more bitcoin will be created after that, unless the code is updated and the miners accept the changes.
Earlier, I mentioned the error that was solved with the short circuit code. Because the numbers are represented in 64 bits, you cannot shift them more than 63 times without getting an error. So the developers updated the code to include this circuit breaker to just return 0 instead of doing the right bit shift operation, even though this code will not be needed for over 100 years after the last satoshi is actually mined.
What does this look like?
https://www.coindesk.com/learn/bitcoin-halving-explained/
The chart above from coindesk does a great job of visualizing the supply of bitcoin reaching around 21mm when the block subsidy hits 0. I have also recorded a video where I walk through an Excel spreadsheet and look a little closer at how the math works.
Disclaimer
We, Digital Opportunities Group, LLC, are not providing investment or other advice. Nothing that we post on Substack should be construed as personalized investment advice or a recommendation that you buy, sell, or hold any security or other investment or that you pursue any investment style or strategy.
Case studies may be included for informational purposes only and are provided as a general overview of our general investment process. We have compiled our research in good faith and use reasonable efforts to include accurate and up-to-date information. In no event should we be responsible or liable for the correctness of any such research or for any damage or lost opportunities resulting from use of our data.
We are not responsible for the content of any third-party websites and we do not endorse the products, services, or investment recommendations described or offered in third-party social media posts and websites.
Nothing we post on Substack should be construed as, and may not be used in connection with, an offer to sell, or a solicitation of an offer to buy or hold, an interest in any security or investment product.