# How to calculate circulating supply for geth private network? [closed]

SUBJ. I have geth private network with custom reward progression and looking for a way to calculate circulating supply.

You would have to go through the block number ranges in which you expect the reward to change, and their respective block rewards in order to calculate the circulating supply.

Here is a golang example, supposing you have an ordered slice consisting in the last block number of each range and its respective block reward, you could do something like this:

``````package main

import (
"fmt"
"math/big"
)

type BlockRange struct {
lastBlockNumber *big.Int
reward          *big.Int
}

func main() {

blockRanges := []BlockRange{
BlockRange{
lastBlockNumber: big.NewInt(500),
reward:          big.NewInt(2e+18),
},
BlockRange{
lastBlockNumber: big.NewInt(1000),
reward:          big.NewInt(1e+18),
},
BlockRange{
lastBlockNumber: big.NewInt(1500),
reward:          big.NewInt(5e+17),
},
}

currentBlockNumber := big.NewInt(1357)
circulatingSupply := big.NewInt(0)

for i, blockRange := range blockRanges {

lastBlockNumber := blockRange.lastBlockNumber
multiplier := big.NewInt(0)

if i == 0 {
multiplier = lastBlockNumber
} else if currentBlockNumber.Cmp(lastBlockNumber) >= 0 {
multiplier.Sub(lastBlockNumber, blockRanges[i-1].lastBlockNumber)
} else {
multiplier.Sub(lastBlockNumber, currentBlockNumber)
}

}

fmt.Println("Circulating supply: ", circulatingSupply)
}
``````

Modify the BlockReward slice initialization with your private network values.

Try this example in the Go Playground

• You would have to take into consideration uncle blocks they have a small reward and modify the block's reward.
– Ismael
May 12, 2019 at 3:40
• Thanks. Figured it a while ago. Made a python script that calculates all rewards including uncles. May 24, 2019 at 10:14