0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

准确计算Ethereum的发行量(流通量)

0
Posted at

最初的标题是 《计算Ethereum的流通量》

流通量感觉不太准确,按照本人的理解 流通量 是指在这个网络中里能用于交换的数量。 而Ethereum网络中,存在着大量的丢失的 /锁定的币,这些是不用于流通的,
但是很难统计,很多网站都用流通量。所以混用了这个说法,流通量即发行量。

计算bitcoin的发行量

先普及下bitcoin的发行量,是很容易计算的,bitcoin只有一种方式可以增发,那就是挖矿奖励。
btc遵循这种规律,第一次的21w (210000)高度的时候,每挖出一个块奖励50个btc。
下一次的21w,也就是 21w~42w高度。每挖出一个块奖励25个btc。每21w个高度就是一个减半周期,挖出的奖励减半了。

btc的发行量 跟块高度紧密相关
咋计算42w个块发行了多少btc呢? 21w * 50 + 21w*25
如果是50w呢? 21w * 50 + 21w*25 + (50w-42w)*12.5

现在高度是[532223 ]现在高度是532223 ,发行量是多少呢? 大家感兴趣的话,可以计算下哈

bitcoin总量还有个上限,就是不超过2100w个。

计算ethereum的发行量

ethereum的发行量比较麻烦了,有四种增发方式

  • Pre-mine(挖矿前)
  • Block rewards(区块奖励)
  • Uncle rewards(叔块奖励)
  • Uncle referencing rewards(叔块引用奖励)

挖矿前: 72 009 990.50 Eth

区块奖励:
区块奖励在4370000高度前都是 5Eth
4370000后,eth启动大都会后奖励变成3Eth

叔块奖励:
计算公式 (uncle_num + 8 - block_num) * R / 8
R是定值,在4370000高度前都是 5Eth,4370000高度后变成3Eth

叔块引用奖励:
如果block 不单有父块,还引用叔块,block有额外的奖励
计算公式 1/32*R*uncle_count (0 ≤ uncle_count ≤ 2)
R是定值,在4370000高度前都是 5Eth,4370000高度后变成3Eth

这需要找出所有引用的叔块,并计算每个叔块的奖励
eth 总量目前没有上限

数据库记录了这些数据

select count(*) from  block_rewards;

  count  
---------
 5903060

select count(*) from  uncle_rewards;

 count  
--------
 657883

select sum(reward) from  block_rewards;

    sum       
----------------
 26532159.15625

select sum(reward) from  uncle_rewards;

    sum     
-------------
 1933525.625


select 26532159.15625 + 1933525.625 + 72009990.50 as total;

    total      
-----------------
 100475675.28125

目前遍历了 5903055 区块高度的eth块数据以及叔块数据,计算出的发行量是 100 475 675.28125,有一定的误差。


参考:

https://etherscan.io/stat/supply
https://ethereum.stackexchange.com/questions/27172/different-uncles-reward

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?