TLDR:
Bitcoin Halvings are pre-programmed and halve the block rewards every 4 years. In under 2 days time at block number 840,000 we’ll get the 4th halving!
The halving code is incredibly simple and elegant, it’s only 6 lines of code and you can learn how it works by reading below.
The result is that Bitcoin’s supply curve approximates precious metals like gold, with most of the coins mined early and them being harder to mine over time.
Price has historically gone up after a halving, one of the key factors is the impact on miners who are forced to sell less BTC.
This halving we’ll also have the release of Bitcoin Runes, a new fungible token standard on Bitcoin created by the Casey Rordamor who created Ordinals.
The biggest and most important thing of this week is the Bitcoin Halving, so it’s a no brainer to discuss it today.
If you’ve been in crypto long enough you’ll know most of this, but you may not have taken a look at the code behind it as we will below.
Bitcoin Halving
Bitcoin is programmed to produce 1 new block on average every 10 minutes. For each new block mined, miners are allowed to reward themselves a maximum “block subsidy” in a transaction known as the “coinbase transaction” that sits at the start of a block and essentially creates new Bitcoin out of nothing.
This coinbase transaction is super important because it’s what introduces new Bitcoin into the overall system and is known as mining new Bitcoin! In principle miners can introduce less than the maximum “subsidy” but that would be silly because they’d be rewarding themselves less, so they practically always mine the full block reward.
At every 210,000 blocks, which is approximately every 4 years, this maximum block reward is halved - this is known as the “Bitcon Halving”!
On releasing this post we’re currently approximately 1 day and 5 hours away from block 840,000, which will mark the 4th Bitcoin Halving event.
Bitcoin began with a block subsidy of 50 BTC per block and dropped sequentially down to 25 BTC, 12.5 BTC, 6.25 BTC and will now drop to 3.125 BTC per block. And this trend means that there will never be more than 21 million BTC in circulation!
Today over 93.5% of all Bitcoin that will ever exist has already been mined, in fact over half was mined in only the first 4 years of its existence.
If you’re interested you can see a fascinating visual animation of the Halving’s effect on Bitcoin’s total supply in this tweet.
The Halving Code
Bitcoin is in some ways a messy system with people spread all over the world vying to influence and participate in it. Yet in other ways it’s incredibly elegant, and the “Halving” code is a great example of this elegance.
You can find Bitcoin’s pre-programmed halving code in it’s GitHub repo in the function “GetBlockSubsidy()”, that sets the maximum reward per block.
Clearly the code for this function is incredibly short and elegant. If you remove comments and empty lines, it’s essentially only 6 lines of code!
Taking a quick look line by line we first see that the current “halving” is found by dividing the current block height by the “halving interval”, that’s predefined as 210,000 blocks. By storing this variable as an “int”, the result of this division is truncated meaning all decimal places are thrown away.
Therefore anything below 210,000 = 0, below 420,000 = 1, below 630,000 = 2, below 840,000 = 3, and below 1,050,000 = 4, etc. So in a couple of days once we’ve passed block 840,000 we’ll move into the era of the 4th halving!
You can also see that in a far future when we get beyond the 64th halving, the function will simply return a block reward of 0 BTC as all possible BTC will have been mined.
For the first 64 halvings though it takes the original subsidy of 50 BTC and halvens it a proportional number of times to the number of halvenings. So now on halving 4 it will halve it 4 times. It does this through an elegant and simple “bit shift” operation:
nSubsidy >>= halvings
This works because integers are essentially sequences of 1s and 0s stored in a binary representation, and so a bit shift to the right will remove a 0 from a number. As an example 1000 » 1 = 100, this is a division by 2 in binary, ie. halves the number.
If you’re not familiar with binary, you can compare with the decimal system. In decimals 1,000 (one thousand) bit shifted right = 100 (one hundred), which is a division by 10. Meanwhile in binary 1000 (sixteen) bit shifted right = 100 (eight), a division by 2.
The Result
From this short but elegant code we get this profound and continuous halving effect of the block reward every 210,000 blocks. Starting with a 50 BTC reward and continuously halving onwards for a total of 64 times until no more BTC can be mined.
A halving occurs approximately every 4 years. This is because 1 block is mined around every 10 minutes, and there are 365 days * 24 hours * 60 minutes = 525,600 minutes in a year, so that’s 52,560 blocks per year, and 210,000 / 52,560 blocks = 3.99 years!
We can approximate the outcome of the code to something very similar to a logarithmic curve trending to 21M as shown below. Note that this image was drawn in 2018 but it still stands as the trend has been pre-programmed from Bitcoin’s inception.
This trend was programmed intentionally to try and emulate how rare metals like gold and platinum tend to be mined.
Gold is a rare metal that cannot be created by humans (at least not yet) it can only be mined in scarce quantities underground. In the past it was easier to find, but as humans mined more and more gold, it became harder to extract with more energy and complex machinery being needed to mine an ever smaller supply of gold on the planet.
The outcome is that larger quantities of gold were extracted at a cheaper price to start, and over time ever smaller quantities required more energy, just like Bitcoin!
These scarce properties we see in gold are a key part of what makes it command the highest market capitalisation of any asset on the planet. Emulating this core scarctiy characteristic of gold was exactly what Satoshi Nakamoto wanted built into Bitcoin.
The Effect on Price
Bitcoin’s pre-programmed scarcity is an important feature, and is a big part of why Bitcoin has experienced a continuous rise in price. And every single Bitcoin halving has historically caused a large run up in price in the months that followed.
One of the key factors in this is that on the Halving block we suddenly see the economics of Bitcoin change dramatically for miners.
Not only do miners earn half the amount of BTC per day that they were previously earning, but their cost of mining also literally doubles as they they pay the same amount in electricity to get half the number of BTC rewards! This mining cost eventually re-adjusts but there’s a significant lag before it does.
This two-pronged effect on miners means that they simply cannot sell as much BTC into the market as before, so there’s less sell pressure. Plus there’s a big incentive to just hold onto the more expensive BTC mined today to offset this cost in the future, reducing their likelihood to sell even further.
Since miners are one of the most steady sellers on the market, all of this activity helps to set up a new demand and supply equilibrium pushing the price of Bitcoin up.
Plan B created Bitcoin’s Stock-to-flow model comparing this mining output to that of precious metals like gold, as discussed above. The S2F model strongly correlates the reduction in supply with an increase in price and has generally been quite accurate.
Of course no model is perfect and the S2F’s accuracy in the past isn’t enough to guarantee the future. Moreover Bitcoin’s price is a complex system and the impact of miners has become lower at every halving since the inflation rate is lower.
Although nobody can predict the future and be 100% certain what we’ll get this time around, my gut feeling is we’ll see a very similar upward trend in Bitcoin price with history repeating itself in some form.
Runes
For anyone who’s been paying attention to the Ordinals ecosystem on Bitcoin this 4th Bitcoin Halving will also come with an additional unlock on the Bitcoin blockchain, namely that Bitcoin “Runes” will become active!
Bitcoin Runes are a new standard from Casey Rordamor, the creator of Ordinals that introduces a “fungible token” standard on Bitcoin just as Ordinals introduced a “non-fungible” standard, and they deserve a whole post of their own.
For now though it suffices to say that Runes will allow people to create new tokens on Bitcoin, just like Ethereum has thousands of ERC20 tokens that live on it. And there’s no doubt this will create a whole new ecosystem of coins just as Ordinals created a new ecosystem of NFTs.
Casey Rordamor has symbolically chosen to make the Runes system go live on block 840,000 when the halving will happen.
So with the Halving only a couple of days away there’s double the reason to be excited, with both the impact on price and the release of Runes!