So what is Bitcoin halving? Halving is an event that reduces the supply of newly produced bitcoins by half. It occurs every four years, or to be precise, every two hundred and ten thousand blocks. The part of the validation logic in the Bitcoin source code about halving is important to discuss, as it affects miners' profitability and often has an impact on the Bitcoin price. It's also one of the main reasons why Bitcoin is perceived as sound money, with the inflation rate steadily trending to zero and becoming deflationary in the long run, in opposition to all the other fiat currencies.
To understand it better, let's quickly recap how miners are rewarded for validating transactions on the Bitcoin network. Transactions on the Bitcoin network are validated and confirmed by miners using a consensus mechanism called proof of work. In proof of work, miners are constantly validating transactions and grouping them in blocks to prove that they did all the necessary work. For the proof of work algorithm, they try to solve a simple but laborious mathematical problem. The first miner who finds the correct solution submits a newly created block to the network and is rewarded for the hard work with a block reward. The block reward consists of two elements: transaction fees and block subsidy. The block subsidy is the number of bitcoins that is subject to the Bitcoin halving.
In January 2009, when the Bitcoin network was started, the first block, called the Genesis block, was mined. According to the algorithm, the block subsidy for the first block started at 50 bitcoins, an arbitrary number chosen by the creator of the network, Satoshi Nakamoto. In November 2012, Bitcoin went through its first halving at the block height of 210,000, where the block reward was cut in half from 50 to 25 bitcoins. At that time, there were already ten and a half million bitcoins in existence. The second halving happened in July 2016 at the block height of 420,000, with 15.75 million bitcoins in circulation. The third highly anticipated halving was expected in May 2020 at the block height of 630,000, with 18.375 million bitcoins in circulation. After that, Bitcoin halvings will occur every four years until roughly the year 2140, when the Bitcoin blockchain reaches the final number of 32 halvings and stops rewarding miners with block subsidy, so they will have to rely solely on transaction fees.
There are a few main reasons why halving matters. The first is sound money theory. Halvings create controlled issuance of Bitcoin, a currency with predictable inflation and eventual deflation when all bitcoins are mined. The current inflation rate is at around 3.6 percent and will decrease to around 1.8 percent after the third halving. The inflation rate will keep decreasing until 2140, when there will be no new supply of bitcoins. After that, Bitcoin becomes deflationary, as some of the already existing bitcoins will be lost.
The second is the price impact caused by a supply shock. Assuming the demand for Bitcoin stays the same and the supply is cut in half, the price of Bitcoin should go up. With the current supply, the market is able to absorb 1,800 new bitcoins per day, considering most miners sell their rewards instead of hoarding them. After the halving, the amount of newly created bitcoins will drop to 900 per day. If demand stays the same, it should increase the price of each coin. Of course, the market is not that easily predictable, and even though previous halvings had an impact on the price, there is no guarantee it will happen again. This is also broadly discussed in the Bitcoin stock-to-flow model, which can be used to try to predict Bitcoin price based on the current stock of coins already in existence and the flow of issuance of new coins.
The third is rewarding early adopters. To incentivize early adopters and help with bootstrapping the network, the inflation rate was the highest at the time the network started. This means early miners were able to receive the highest rewards and accumulate more bitcoins. Looking at the Bitcoin money supply, at the time of creating this video, 18 out of 21 million bitcoins were already mined, which again incentivizes early adopters.
Now let's get a bit more technical and jump into the code that is actually responsible for the Bitcoin halving. This code snippet is taken from the Bitcoin Core GitHub repository, from the validation.cpp file that is responsible, as you may guess, for validation. I will put a link to this piece of code in the description box below. Bitcoin halving, instead of being defined as a time constant, is actually defined using the number of blocks. We can see that the number of halvings is calculated using the current block height and the subsidy halving interval, which is a constant equal to 210,000. This represents the number of blocks after which a halving should occur. Assuming a block is mined on average every ten minutes, it should take roughly four years to mine 210,000 blocks. 619,894 is the current block height at the time of making this video. This means the halving variable is currently set to that number divided by 210,000, which is roughly equal to 2.95, which in integer division is just 2, although it is getting very close to 3.
The next two steps are also quite interesting. We have a check that returns zero when the halving count is greater than or equal to 64, which is mostly used to protect the right shift operator that comes later. This doesn't mean there will be 64 halvings, as we will quickly realize the actual subsidy will be zero from the 33rd halving onwards. The next step is to get the first block subsidy in satoshis. The COIN constant represents one bitcoin in satoshis. Now we get to the actual calculation, which is performed using the right shift bit operator instead of division for performance reasons. If we start with 5 billion and begin right-shifting it, we can quickly see that the maximum number of times we can do it is thirty-two. At the thirty-second attempt, our reward will be one satoshi. If we shift one more time, it will give us zero as the result. We can quickly calculate that if one halving occurs every four years on average, the mining reward will stop around the year 2140. We can get to that number by using the Bitcoin Genesis block date, which is the 3rd of January 2009, and adding 32 times 4 plus 4 to it. This leads us to the 3rd of January, often rounded to 2140, as the final year for Bitcoin mining block subsidy rewards.
Let's see what happens in the code at the next halving, estimated for around the 5th of May 2020, when block height reaches 630,000. The halving variable starts returning 3. After that, we'll be right-bit-shifting, going from 5 billion to 625 million satoshis, which is equal to 6.25 bitcoins, and that will be the new block subsidy reward for the next four years.
Bitcoin halving is one of the most important mechanisms in the Bitcoin network and its monetary system. It allows for a predictable, decreasing inflation rate of the currency and incentivizes early adopters to bootstrap and secure the network. If you want to learn more about Bitcoin and Bitcoin halving, please check the links in the description box below. If you have any questions regarding Bitcoin halving or any suggestions for the next videos, please comment below and also visit my website, cinematix.com. If you liked the video, hit the like button and subscribe to my channel. Thanks for watching.
