Discover more from DigOpp
Understanding Bitcoin Supply
Revisiting the basics of Bitcoin inflation
Each time a block is mined, BTC are created for the miner. This is the only way new BTC can be created and will only happen until around year 2140. This subsidy represents almost all of the revenue that a miner makes and dwarves income from transaction fees paid by users. 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. These subsidies are how each of the 19 million or so BTC that are in circulation now have been created.
The subsidies are paid out whenever a block is mined, but the amount of the subsidy per block decays over time. It started out at 50 BTC per block, and then is cut in half every 210,000 blocks. You may have heard that it is cut in half every 4 years, which is pretty much how the math works out due to the average block time of 10 minutes.
10 min * 210,000 blocks = 2,100,000 minutes per halving
4 years ≈ 2,100,000 minutes
The chart above from coindesk does a great job of visualizing the supply of Bitcoin reaching around 21mm, on the dark line, when the block subsidy hits 0, on the yellow line. Each stair-step on the subsidy line represents the point where the block chain crosses over a new 210,000 block threshold and the subsidy gets cut in half. When this happens, miners begin receiving half as much for cracking a block as they had before. Later in this post, I will walk through the code that governs this and link a video where I dig in a little deeper to the math.
The smallest unit of BTC is referred to as a Satoshi. You can’t have less than 1 Satoshi and there are 100 million Satoshi in each BTC. Similar to how there are 100 pennies in each US dollar. Bitcoin accumulators often refer to the act of accumulating as “stacking sats”. One interesting coincidence is that there are roughly as many pennies in M2 money supply1 as there will be Satoshis at max circulating supply.
As of writing, there are about 21 trillion dollars in M2 money supply. The 21 trillion dollars times the 100 pennies is the same number as the 21 million Bitcoin times 100 million Satoshis. So while 21 million BTC may sound like a small amount, there will be as many Satoshis floating around as there are pennies currently in the nation’s main cash stashes.
Will the supply ever go beyond 21 million?
It’s possible. Currently there are two places in the code that dictate the max amount of Bitcoin, the `GetBlockSubsidy()` function that I will get to in a minute, and the following lines2:
If these lines and the `GetBlockSubsidy()` function were changed and deployed by the Bitcoin Core maintainers, the inflation of Bitcoin would change. Miners and nodes that decided to use the new code would now have a different supply cap than those that do not and would essentially be using a different Bitcoin. Whether or not this will happen and be adopted as the true Bitcoin would be hard to say. It may be in miners’ best interest to continue the subsidies instead of ceasing them, so maybe they would use the new code. Maintainers may be fine with increasing the number or having constant inflation to infinite supply if it improved the health and security of the network. There are over 100 years until the last subsidy is minted, and I’m not sure anyone can say that an increase in supply is impossible before then.
Digging into the code
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 210,000 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.
I have also recorded a video where I walk through an Excel spreadsheet and look a little closer at how the math works.
Thanks for reading DigOpp! Subscribe for free to receive new posts and learn more about digital asset tech and markets.
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.
M2 is a measure of the U.S. money stock that includes M1 (currency and coins held by the non-bank public, checkable deposits, and travelers' checks) plus savings deposits (including money market deposit accounts), small time deposits under $100,000, and shares in retail money market mutual funds. - https://fred.stlouisfed.org/series/M2SL