<p>Yes. Thats possible. I wrote <a href="https://github.com/ndsvw/Bitcoin-Supply-Calculator/blob/master/btcsupply.py" rel="nofollow noreferrer">a python program</a> that returns the supply at a given block (works with future supply, too):</p>

<pre><code>#!/usr/bin/env python
# -*- coding: utf8 -*-

def btcSupplyAtBlock(b):
  reward = 50
  supply = 0
  y = 210000 # reward changes all y blocks
  while b&gt;y:
    supply = supply + y * reward
    reward = reward / 2.0
    b = b - y
  supply = supply + b * reward
  return supply

block = 514227 # you want the supply after which block?
print(btcSupplyAtBlock(block))
</code></pre>

<ul>
<li>supply at block 0: 0</li>
<li>supply at block 100,000: 5,000,000</li>
<li>supply at block 514,227: 16,927,837.5</li>
<li>supply at block 1,000,000: 20,187,500</li>
</ul>

CC BY-SA 3.0
2018-03-19T11:17:54.107Z
nice. can this function also be used for other coins?
AyKarsi
CC BY-SA 3.0
2018-03-19T13:43:35.590Z
Most coins use other reward algorithms. This code works only for Bitcoin and most of its forks (also Bitcoin Cash).
hardfork
CC BY-SA 3.0
2018-03-19T17:46:13.360Z
Note that this algo provides an upper bound on the coin supply, some miners decide not to claim some of the reward they are entitled too, therefore reducing the supply forever. See this [coinbase](https://blockchain.info/tx/5d80a29be1609db91658b401f85921a86ab4755969729b65257651bb9fd2c10d) as example.
alcio
CC BY-SA 3.0
2018-03-19T10:02:31.363Z
2018-03-19T10:02:31.363Z
hardfork
<p>The total number of coins mined/available should be readable from the blockchain. 
But is also possible to calculate the number of coins which were/will be available at any given time? </p>

<market>
Calculate Coin Supply at any given time
AyKarsi
# Calculate Coin Supply at any given time

(Asked by: username_0 on 2018-03-19)

The total number of coins mined/available should be readable from the blockchain.
But is also possible to calculate the number of coins which were/will be available at any given time?

**Tags:** market


---

## 1 answers

### Answer by username_1 on 2018-03-19. Score: 2

Yes. Thats possible. I wrote [a python program](https://github.com/ndsvw/Bitcoin-Supply-Calculator/blob/master/btcsupply.py) that returns the supply at a given block (works with future supply, too):

```
#!/usr/bin/env python
# -*- coding: utf8 -*-

def btcSupplyAtBlock(b):
  reward = 50
  supply = 0
  y = 210000 # reward changes all y blocks
  while b>y:
    supply = supply + y * reward
    reward = reward / 2.0
    b = b - y
  supply = supply + b * reward
  return supply

block = 514227 # you want the supply after which block?
print(btcSupplyAtBlock(block))

```

* supply at block 0: 0
* supply at block 100,000: 5,000,000
* supply at block 514,227: 16,927,837.5
* supply at block 1,000,000: 20,187,500

> **Comments:**
> **username_0**: nice. can this function also be used for other coins?  
> **username_1**: Most coins use other reward algorithms. This code works only for Bitcoin and most of its forks (also Bitcoin Cash).  
> **username_2**: Note that this algo provides an upper bound on the coin supply, some miners decide not to claim some of the reward they are entitled too, therefore reducing the supply forever. See this [coinbase](https://blockchain.info/tx/5d80a29be1609db91658b401f85921a86ab4755969729b65257651bb9fd2c10d) as example.  

---

