{"id":246,"date":"2023-09-16T09:52:06","date_gmt":"2023-09-16T00:52:06","guid":{"rendered":"https:\/\/www.sumitbilashjoshi.com\/?p=246"},"modified":"2024-04-21T20:16:05","modified_gmt":"2024-04-21T11:16:05","slug":"bitcoin-halving-block-subsidy","status":"publish","type":"post","link":"https:\/\/www.sumitbilashjoshi.com\/?p=246","title":{"rendered":"Bitcoin Halving &#038; Block Subsidy"},"content":{"rendered":"\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">Bitcoin Halving<\/mark> is a phenomenon or a certain point in time in Bitcoin protocol where the block subsidy is cut in exact half of what it was before that phenomenon. This rule was written in the Bitcoin code as a way to gradually and consistently issue the amount of BTC over time. The issuance of new <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">BTC<\/mark> begins at a fixed rate and gradually reduces until the total distribution of the coin reaches <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">21,000,000<\/mark>. The code defines when this halving phenomenon occurs and how the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">Block Subsidy<\/mark> is calculated and distributed to the miner.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Once the block is created, the miner sends the newly created block to the node network. And nodes verify that block follows the rules of the network, such as maximum amount of data on the block and maximum number of coins, which is the Block Subsidy that the miner gets rewarded when creating the block. If a node determines that a block is valid, it stores it and propagates it to other nodes, and within a short period of time, every nodes will verify and store this new block to continue the blockchain.<\/p>\n\n\n\n<p>The code contains some rules that decide the timing of the halving and the amount of block subsidy. The block subsidy is cut in half after every <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">210,000 blocks<\/mark>. When Bitcoin protocol was first set live in <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">2009<\/mark>, the initial block subsidy was <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">50 BTC<\/mark>. From the first block of the Bitcoin protocol, there have been <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">3 halvings<\/mark> each after 210,000 blocks. Block subsidies are paid every <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">10 minutes<\/mark> on average. So, the halving occurs around approximately every <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">4 years<\/mark> after 210,000 blocks are mined on the blockchain. <\/p>\n\n\n\n<p>The next or <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">4<sup>th<\/sup> halving<\/mark> is scheduled to occur around <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">April 2024<\/mark>. From that point, the block subsidy is reduced to <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">3.125<\/mark> per block. This Bitcoin Halving and block subsidy will stop when it reaches <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">zero<\/mark> and all the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">21,000,000<\/mark> BTC has been mined. This will occur roughly around the year <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">2140<\/mark>. There will be total of <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">32 halvings<\/mark> and each halving will cut the block subsidy to half of previous block subsidy. Below is the code snippet for receiving the block subsidy.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"311\" src=\"https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/GetBlockSubsidy-1024x311.png\" alt=\"\" class=\"wp-image-250\" srcset=\"https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/GetBlockSubsidy-1024x311.png 1024w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/GetBlockSubsidy-300x91.png 300w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/GetBlockSubsidy-768x234.png 768w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/GetBlockSubsidy-1536x467.png 1536w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/GetBlockSubsidy-2048x623.png 2048w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/GetBlockSubsidy-1200x365.png 1200w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/GetBlockSubsidy-1980x602.png 1980w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This code is what defines the amount of block subsidy and schedule for its reduction to exactly in half of previous amount over that time. The total supply of the Bitcoin will be stopped after 32 halvings once this subsidy reach to <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">Zero<\/mark>. <\/p>\n\n\n\n<p>This line of code calculates the number of halvings.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int halvings = nHeight \/ consensusParams.nSubsidyHalvingInterval;<\/code><\/pre>\n\n\n\n<p>The \u201c<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">halvings<\/mark>\u201d integer will have the rounded down value of the nearest whole number. \u201c<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">nHeight<\/mark>\u201d is the current number of blocks on the blockchain. When the new block is created and added to the blockchain, it grows <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">longer\/taller<\/mark>. As of this writing, bitcoin\u2019s \u201c<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">block height<\/mark>\u201d is <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">807892<\/mark> blocks. \u201c<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">nSubsidyHalvingInterval<\/mark>\u201d is the number of block which must pass before another halving occurs which has the static value set to <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">210,000<\/mark> blocks as defined in the bitcoin codebase below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"427\" src=\"https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/Blocks-1024x427.png\" alt=\"\" class=\"wp-image-251\" srcset=\"https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/Blocks-1024x427.png 1024w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/Blocks-300x125.png 300w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/Blocks-768x320.png 768w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/Blocks-1200x500.png 1200w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/Blocks.png 1286w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\"><strong>The Block Subsidy<\/strong><\/mark><\/p>\n\n\n\n<p>This code below has the constant <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">COIN<\/mark>. Let\u2019s look at what that means.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CAmount nSubsidy = 50 * COIN;<\/code><\/pre>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">COIN<\/mark> is a value specified in the code as below. It is the total smallest divisible units of a bitcoin, which is <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">satoshi<\/mark>. There are <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">100,000,000<\/mark> satoshis in <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">1 BTC<\/mark>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/** The amount of satoshis in one BTC. *\/ static constexpr CAmount COIN = 100000000;<\/code><\/pre>\n\n\n\n<p>So the subsidy is multiplied by the number of coins which is satoshis. If the block subsidy is <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">50 BTC<\/mark>, the subsidy or reward will be <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">5,000,000,000 satoshis<\/mark>.<\/p>\n\n\n\n<p>The comment below describes that the block subsidy is cut in half every <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">210,000<\/mark> blocks or approximately <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">4<\/mark> years.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.\nnSubsidy &gt;&gt;= halvings;<\/code><\/pre>\n\n\n\n<p>Let\u2019s look at the code above. The most important part here is the \u201d<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">&gt;&gt;<\/mark>\u201d operator or its also known as \u201c<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">bitwise right shift<\/mark>\u201d. It\u2019s a standard operator in C++ programming language and is very important here. It is same as dividing by 2. Let\u2019s look at the example of current halving period which is <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">3<sup>rd<\/sup><\/mark> halving. The <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">nSubsidy<\/mark> is fixed number which is <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">50 * 100,000,000(50 BTC)<\/mark> and the operator is &gt;&gt; 3. The binary value of the <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">50 * 100000000<\/mark> is \u201c<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">100101010000001011111001000000000<\/mark>\u201d. A single bitwise right shift removes the last digit on the far right from the binary number. Converting this binary number to the decimal value, it gives the subsidy at the first halving.<\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">100101010000001011111001000000000<\/mark> = <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">5,000,000,000<\/mark> satoshis = 50 BTC<\/p>\n\n\n\n<p>After the first halving, <\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">10010101000000101111100100000000<\/mark> = <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">2,500,000,000<\/mark> satoshis = 25 BTC<\/p>\n\n\n\n<p>After the second halving, <\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">1001010100000010111110010000000<\/mark> = <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">1,250,000,000 <\/mark>satoshis = 12.5 BTC<\/p>\n\n\n\n<p>As its the 3<sup>rd<\/sup> halving period now, <\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">100101010000001011111001000000<\/mark> = <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">625,000,000<\/mark> satoshis = 6.25 BTC<\/p>\n\n\n\n<p>The next halving is scheduled to occur around April 2024. The block subsidy will be,<\/p>\n\n\n\n<p><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">10010101000000101111100100000<\/mark> = <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">312,500,000<\/mark> = 3.125 BTC<\/p>\n\n\n\n<p>This way the block subsidy get cut in <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">half<\/mark> every <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">210,000<\/mark> blocks.<\/p>\n\n\n\n<p>I&#8217;ve created a table below to calculate the number of BTCs to be mined after each halving and it\u2019s amazing and fun to see how it works.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"758\" height=\"1024\" src=\"https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/HalvingTable-1-758x1024.png\" alt=\"\" class=\"wp-image-253\" srcset=\"https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/HalvingTable-1-758x1024.png 758w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/HalvingTable-1-222x300.png 222w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/HalvingTable-1-768x1038.png 768w, https:\/\/www.sumitbilashjoshi.com\/wp-content\/uploads\/2023\/09\/HalvingTable-1.png 984w\" sizes=\"auto, (max-width: 758px) 100vw, 758px\" \/><\/figure>\n\n\n\n<p>If you look at the number of BTC scheduled to get mined in the year <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">2100<\/mark>, it\u2019s less than <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">3<\/mark> BTC in <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">4 <\/mark>years. The highlighted data in the period from the year <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">2104<\/mark> to <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">2140<\/mark> is mind blowing. It will take approximately <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">36 years<\/mark> for all the energy of miners and the computing power of the world to mine <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">single<\/mark> <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">BTC<\/mark>. We can not even imagine how valuable this asset will be <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">100<\/mark> years from now. The meaning of value exchange will be completely different from how our mind can comprehend today. Future looks so bright for coming generation. Bitcoin is a <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">war<\/mark> without <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-accent-color\">violence<\/mark> and its incentives are so high, noone and no country can ignore or escape.<\/p>\n\n\n\n<p id=\"wp-block-themeisle-blocks-advanced-heading-15dd99e6\" class=\"wp-block-themeisle-blocks-advanced-heading wp-block-themeisle-blocks-advanced-heading-15dd99e6\">&#8220;&#8230;The greatest victory is that which requires no battle&#8230;.&#8221;<\/p>\n\n\n\n<div id=\"wp-block-themeisle-blocks-advanced-columns-02d86e0d\" class=\"wp-block-themeisle-blocks-advanced-columns alignfull has-1-columns has-desktop-equal-layout has-tablet-equal-layout has-mobile-collapsedRows-layout has-vertical-center ticss-c00aadba\"><div class=\"wp-block-themeisle-blocks-advanced-columns-overlay\"><\/div><div class=\"innerblocks-wrap\">\n<div id=\"wp-block-themeisle-blocks-advanced-column-853c0cd5\" class=\"wp-block-themeisle-blocks-advanced-column\">\n<p id=\"wp-block-themeisle-blocks-advanced-heading-0d3c3162\" class=\"wp-block-themeisle-blocks-advanced-heading wp-block-themeisle-blocks-advanced-heading-0d3c3162\"><strong>Sun Tzu, The Art of War<\/strong><\/p>\n<\/div>\n<\/div><\/div>\n\n\n\n<p>I\u2019ve written about the <a href=\"https:\/\/www.sumitbilashjoshi.com\/?p=224\" target=\"_blank\" rel=\"noopener\" title=\"\">Value Exchange<\/a> and <a href=\"https:\/\/www.sumitbilashjoshi.com\/?p=191\" target=\"_blank\" rel=\"noopener\" title=\"\">Money<\/a> prior to this article. You might want to check those out. I\u2019ll write about the bitcoin code in future articles too.<\/p>\n\n\n\n<p>Thank you for reading. See you next time.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bitcoin Halving is a phenomenon or a certain point in time in Bitcoin protocol where the block subsidy is cut in exact half of what it was before that phenomenon. This rule was written in the Bitcoin code as a way to gradually and consistently issue the amount of BTC over time. The issuance of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":258,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[5,17],"tags":[8,18],"class_list":["post-246","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-economics","category-technology","tag-bitcoin","tag-technology"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.sumitbilashjoshi.com\/index.php?rest_route=\/wp\/v2\/posts\/246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sumitbilashjoshi.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sumitbilashjoshi.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sumitbilashjoshi.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sumitbilashjoshi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=246"}],"version-history":[{"count":7,"href":"https:\/\/www.sumitbilashjoshi.com\/index.php?rest_route=\/wp\/v2\/posts\/246\/revisions"}],"predecessor-version":[{"id":385,"href":"https:\/\/www.sumitbilashjoshi.com\/index.php?rest_route=\/wp\/v2\/posts\/246\/revisions\/385"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sumitbilashjoshi.com\/index.php?rest_route=\/wp\/v2\/media\/258"}],"wp:attachment":[{"href":"https:\/\/www.sumitbilashjoshi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sumitbilashjoshi.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sumitbilashjoshi.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}