<p>As Artefact2 mentioned, Bitcoin uses fixed-point math to calculate the block subsidies. So, ignoring the unspendable genesis block, the sundry lost coins and unclaimed rewards, the maximum number of bitcoins is 20999999.9769 BTC.</p>

<p>I found that number through the following python program:</p>

<pre><code>COIN = 100 * 1000 * 1000
nSubsidy = 50 * COIN
nHeight = 0
total = 0
while nSubsidy != 0:
    nSubsidy = 50 * COIN
    nSubsidy &gt;&gt;= nHeight / 210000
    nHeight += 1
    total += nSubsidy

print total / float(COIN)
</code></pre>

<p>It's intended to mirror this code from the Bitcoin client:</p>

<pre><code>int64 static GetBlockValue(int nHeight, int64 nFees)
{
    int64 nSubsidy = 50 * COIN;

    // Subsidy is cut in half every 210000 blocks, which will occur approximately every 4 years
    nSubsidy &gt;&gt;= (nHeight / 210000);

    return nSubsidy + nFees;
}
</code></pre>

<p>Of course, it only differs from 21 million BTC by only 3 bitcents, so the difference isn't significant.</p>

CC BY-SA 3.0
2013-04-18T22:21:34.420Z
2013-04-18T22:21:34.420Z
Nick ODell
<p>Every block introduces 50 new coins in the system. This quantity (50) halves every 210,000 blocks. So, getting the limit of coins it is possible to generate is quite easy : it's the sum of a geometric series.</p>

<p><img src="https://i.sstatic.net/tTVgM.gif" alt="latex formula"></p>

<p>Also, note that this is an upper bound ; the actual quantity will probably be a bit lower due to rounding issues (BTC has a finite number of decimals, 8).</p>

CC BY-SA 3.0
2012-11-19T22:34:39.197Z
Artefact, yes but that is not the theoretical limit... Basically its (10^8)... 100,000,000
intmain
CC BY-SA 3.0
2011-08-31T12:16:34.410Z
2011-08-31T12:16:34.410Z
Artefact2
<p>According to a BIP (Bitcoin Improvement Proposal) I found, this code:</p>

<pre><code> nSubsidy &gt;&gt;= (nHeight / 210000);
</code></pre>

<p>will actually wrap the reward generation back to 50 at some point in 2200 or so. Making the supply of bit coins infinite. The python code above does not have this property. The C++ code does. See BIP <a href="https://github.com/bitcoin/bips/blob/master/bip-0042.mediawiki" rel="noreferrer">https://github.com/bitcoin/bips/blob/master/bip-0042.mediawiki</a></p>

CC BY-SA 3.0
2015-08-13T22:29:48.817Z
This is actually the right answer. Unfortunately many people are not aware of it because they don't do C++.
Gregory Higley
CC BY-SA 3.0
2016-02-26T17:31:03.860Z
Carefully note the date on that BIP.
David Schwartz
CC BY-SA 3.0
2017-08-11T08:53:59.177Z
You should provide a little more details: are you talking of an integer overflow case? Is this code located in the reference implementation or in a pull request proposed by a BIP, and which one? Is it a tracked bug?
PPC
CC BY-SA 3.0
2014-07-18T18:35:01.737Z
2014-07-18T18:35:01.737Z
Thomas Jay Rush
<p>As per the <strong>current rules</strong> there will only ever be 21 million coins at most (explained in other answers here). However, I'd like to add that this is by general agreement, which means that it <strong>can be changed</strong>.</p>

<p>See this question: <a href="https://bitcoin.stackexchange.com/questions/8776/could-there-be-hyperinflation-in-bitcoin">Could there be hyperinflation in Bitcoin?</a></p>

<p>Looking at the history of money, I am skeptical that there will only ever be 21 million coins. I don't know of too many instances in history when money could be created out of thin air and wasn't. It would be foolish to ignore history. Whether or not there will be more than 21 million coins depends on whether or not "the people" demand it, and once again history is our guide.</p>

CC BY-SA 3.0
2013-04-19T12:13:17.180Z
2013-04-19T12:13:17.180Z
2017-04-13T12:47:33.743Z
Manish
<p>Re. 'how is it enforced?': 
The 21 million limit is enforced by game theory. Theoretically, 50% of miners could adopt code that would increase the rate of production but this would break the social contract that Satoshi created, irrevocably harm the integrity of bitcoin, and crash the price. Therefore, anyone or any group that could change the limit is incentivized to not do so.  </p>

CC BY-SA 3.0
2016-07-21T10:34:56.840Z
This is incorrect. Full nodes in the network validate all blocks, and if miners would adapt their code to increase the amount of money printed, their blocks would be invalid, and simply ignored by the network. Of course, miners could also try to convince the entire ecosystem to adopt the new rules, but that's much more complicated than just game theory.
Pieter Wuille
CC BY-SA 3.0
2016-11-08T21:59:48.650Z
Saying, "miners could also try to convince the entire ecosystem to adopt the new rules," is wrong, I think. Wouldn't it just have to be 51% not the entire ecosystem?
Thomas Jay Rush
CC BY-SA 3.0
2017-12-16T10:56:17.467Z
@AlexMillar The limit is enforced by the social contract. That contract is understood in terms of game theory.
Volker Siegel
CC BY-SA 3.0
2016-02-26T16:25:01.450Z
2016-02-26T16:25:01.450Z
Alex Millar
<p>I wrote a <a href="https://osolmaz.com/2019/02/09/inflation-curvature-bitcoin-supply/" rel="nofollow noreferrer">detailed analysis</a> of the supply and inflation in Bitcoin, for those who are interested in the math behind it. Below is a formula expressing Bitcoin supply as a function of block height:</p>

<p><a href="https://i.sstatic.net/v1Zeg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/v1Zeg.png" alt="enter image description here"></a></p>

<p>where S is supply, h is block height, alpha=1/2, beta=210,000, R_0=50 and topless square braces denote the floor function.</p>

<p>Taking its limit as h-> infinity, we arrive at the same result provided by @Artefact2.</p>

CC BY-SA 4.0
2019-02-09T12:03:32.567Z
2019-02-09T15:41:11.627Z
2019-02-09T15:41:11.627Z
osolmaz
<p>A pre-defined schedule limits the total number of bitcoins so that they gradually approach a total of 21 million (ignoring those that have been lost through deleted or misplaced wallet files).  <strong>The limit of 21 million bitcoins is "hard-wired" in to the protocol</strong>, and there will never be more bitcoins than this:</p>

<p><img src="https://i.sstatic.net/JLm1p.png" alt="The Schedule on which Bitcoins are released into the economy through being rewarded to miners"></p>

CC BY-SA 3.0
2016-02-26T16:30:06.270Z
I think saying "hard wired" is a bit misleading. The production schedule is coded in the software and could be changed to create more bitcoin. Fortunately anyone or any group that could change it is strongly incentivized to maintain the limit as it is integral to our idea of and trust in bitcoin.
Alex Millar
CC BY-SA 3.0
2011-08-31T00:00:03.530Z
Note that there are some assumptions built into the timing and unless the protocol is changed, they will actually be mined a bit earlier than this chart suggests.
David Schwartz
CC BY-SA 3.0
2011-08-31T00:02:37.397Z
Or later--if the value drops precipitously and difficulty takes a while to get low enough again.  But the graph is a good rough approximation.
eMansipater
CC BY-SA 3.0
2011-08-31T00:04:11.590Z
I think that's very unlikely. Even if there are a few precipitous drops, I think that will be outweighed by the overall trend of increasing hashing power (and they'll be followed be precipitous drops in difficulty). But, yes, that is possible.
David Schwartz
CC BY-SA 3.0
2011-08-30T23:57:34.970Z
2011-08-30T23:57:34.970Z
eMansipater
<p>Since bitcoins are being regularly rewarded to <a href="https://en.bitcoin.it/wiki/Category%3aMining">miners</a>, will the number of bitcoins continue to grow indefinitely, or will there be a maximum total number of bitcoins in existence?  And if there is some kind of limit, what is it and how is it enforced?</p>

<reward-schedule>
How many bitcoins will there eventually be?
eMansipater
# How many bitcoins will there eventually be?

(Asked by: username_0 on 2011-08-30)

Since bitcoins are being regularly rewarded to [miners](https://en.bitcoin.it/wiki/Category%3aMining), will the number of bitcoins continue to grow indefinitely, or will there be a maximum total number of bitcoins in existence? And if there is some kind of limit, what is it and how is it enforced?

**Tags:** reward-schedule


---

## 7 answers

### Answer by username_0 on 2011-08-30. Score: 41 | Accepted answer

A pre-defined schedule limits the total number of bitcoins so that they gradually approach a total of 21 million (ignoring those that have been lost through deleted or misplaced wallet files). **The limit of 21 million bitcoins is "hard-wired" in to the protocol**, and there will never be more bitcoins than this:

![The Schedule on which Bitcoins are released into the economy through being rewarded to miners](https://i.sstatic.net/JLm1p.png)

> **Comments:**
> **username_6**: Note that there are some assumptions built into the timing and unless the protocol is changed, they will actually be mined a bit earlier than this chart suggests.  
> **username_0**: Or later--if the value drops precipitously and difficulty takes a while to get low enough again.  But the graph is a good rough approximation.  
> **username_6**: I think that's very unlikely. Even if there are a few precipitous drops, I think that will be outweighed by the overall trend of increasing hashing power (and they'll be followed be precipitous drops in difficulty). But, yes, that is possible.  
> **username_9**: I think saying "hard wired" is a bit misleading. The production schedule is coded in the software and could be changed to create more bitcoin. Fortunately anyone or any group that could change it is strongly incentivized to maintain the limit as it is integral to our idea of and trust in bitcoin.  

---

### Answer by username_2 on 2011-08-31. Score: 50

Every block introduces 50 new coins in the system. This quantity (50) halves every 210,000 blocks. So, getting the limit of coins it is possible to generate is quite easy : it's the sum of a geometric series.

![latex formula](https://i.sstatic.net/tTVgM.gif)

Also, note that this is an upper bound ; the actual quantity will probably be a bit lower due to rounding issues (BTC has a finite number of decimals, 8).

> **Comments:**
> **username_3**: Artefact, yes but that is not the theoretical limit... Basically its (10^8)... 100,000,000  

---

### Answer by username_1 on 2013-04-18. Score: 14

As username_2 mentioned, Bitcoin uses fixed-point math to calculate the block subsidies. So, ignoring the unspendable genesis block, the sundry lost coins and unclaimed rewards, the maximum number of bitcoins is 20999999.9769 BTC.

I found that number through the following python program:

```
COIN = 100 * 1000 * 1000
nSubsidy = 50 * COIN
nHeight = 0
total = 0
while nSubsidy != 0:
    nSubsidy = 50 * COIN
    nSubsidy >>= nHeight / 210000
    nHeight += 1
    total += nSubsidy

print total / float(COIN)

```

It's intended to mirror this code from the Bitcoin client:

```
int64 static GetBlockValue(int nHeight, int64 nFees)
{
    int64 nSubsidy = 50 * COIN;

    // Subsidy is cut in half every 210000 blocks, which will occur approximately every 4 years
    nSubsidy >>= (nHeight / 210000);

    return nSubsidy + nFees;
}

```

Of course, it only differs from 21 million BTC by only 3 bitcents, so the difference isn't significant.


---

### Answer by username_4 on 2014-07-18. Score: 9

According to a BIP (Bitcoin Improvement Proposal) I found, this code:

```
 nSubsidy >>= (nHeight / 210000);

```

will actually wrap the reward generation back to 50 at some point in 2200 or so. Making the supply of bit coins infinite. The python code above does not have this property. The C++ code does. See BIP <https://github.com/bitcoin/bips/blob/master/bip-0042.mediawiki>

> **Comments:**
> **username_5**: This is actually the right answer. Unfortunately many people are not aware of it because they don't do C++.  
> **username_6**: Carefully note the date on that BIP.  
> **username_7**: You should provide a little more details: are you talking of an integer overflow case? Is this code located in the reference implementation or in a pull request proposed by a BIP, and which one? Is it a tracked bug?  

---

### Answer by username_8 on 2013-04-19. Score: 6

As per the **current rules** there will only ever be 21 million coins at most (explained in other answers here). However, I'd like to add that this is by general agreement, which means that it **can be changed**.

See this question: [Could there be hyperinflation in Bitcoin?](https://bitcoin.stackexchange.com/questions/8776/could-there-be-hyperinflation-in-bitcoin)

Looking at the history of money, I am skeptical that there will only ever be 21 million coins. I don't know of too many instances in history when money could be created out of thin air and wasn't. It would be foolish to ignore history. Whether or not there will be more than 21 million coins depends on whether or not "the people" demand it, and once again history is our guide.


---

### Answer by username_9 on 2016-02-26. Score: 1

Re. 'how is it enforced?':
The 21 million limit is enforced by game theory. Theoretically, 50% of miners could adopt code that would increase the rate of production but this would break the social contract that Satoshi created, irrevocably harm the integrity of bitcoin, and crash the price. Therefore, anyone or any group that could change the limit is incentivized to not do so.

> **Comments:**
> **username_10**: This is incorrect. Full nodes in the network validate all blocks, and if miners would adapt their code to increase the amount of money printed, their blocks would be invalid, and simply ignored by the network. Of course, miners could also try to convince the entire ecosystem to adopt the new rules, but that's much more complicated than just game theory.  
> **username_4**: Saying, "miners could also try to convince the entire ecosystem to adopt the new rules," is wrong, I think. Wouldn't it just have to be 51% not the entire ecosystem?  
> **username_11**: @username_9 The limit is enforced by the social contract. That contract is understood in terms of game theory.  

---

### Answer by username_12 on 2019-02-09. Score: 0

I wrote a [detailed analysis](https://username_12.com/2019/02/09/inflation-curvature-bitcoin-supply/) of the supply and inflation in Bitcoin, for those who are interested in the math behind it. Below is a formula expressing Bitcoin supply as a function of block height:

[![enter image description here](https://i.sstatic.net/v1Zeg.png)](https://i.sstatic.net/v1Zeg.png)

where S is supply, h is block height, alpha=1/2, beta=210,000, R\_0=50 and topless square braces denote the floor function.

Taking its limit as h-> infinity, we arrive at the same result provided by @username_2.


---

