I am not able to understand how circulating supply is calculated by websites like CoinGecko. What does circulating supply mean here - is it the number of coins already minted? If so, how is that calculated?
Asked
Active
Viewed 123 times
0
-
1I am not sure how different websites calculate it but here's a way to do it considering all the exceptions since 2009: https://bitcoin.stackexchange.com/a/38998/ – Oct 10 '21 at 03:06
1 Answers
1
- The first blocks had a 50 BTC subsidy
- The subsidy of block 0 is unspendable
- This subsidy is cut in half every 210.000 blocks
- Block height now is 704558
This script (in Ruby) calculates the total amount of Bitcoins issued.
#!/usr/bin/env ruby
first 210.000 blocks get 50 BTC as subsidy.
for every 210.000 blocks, the subsidy is cut in half.
global constants
SATOSHIS_PER_COIN = 100000000
BLOCKS_PER_EPOCH = 210000
given a block height, returns the subsidy for that block
def block_subsidy(block_height)
epoch = block_height / BLOCKS_PER_EPOCH
subsidy = 50 * SATOSHIS_PER_COIN
subsidy >> epoch
end
get block height from command line or use last block with subsidy
last_block = (ARGV[0] || 6929999).to_i
total supply, use 0.0 to make it a float
total_supply = 0.0
starts with 1 since subsidy of block 0 is unspendable
for height in 1..last_block
total_supply += block_subsidy(height)
end
show total supply in bitcoins
puts total_supply / SATOSHIS_PER_COIN
Having said that, there were some issues in some blocks, so the true total supply will be slightly less than this.

bordalix
- 487
- 3
- 11