# Bitcoin halving code **Published by:** [willzm.eth](https://paragraph.com/@willzm/) **Published on:** 2021-10-20 **URL:** https://paragraph.com/@willzm/bitcoin-halving-code ## Content CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { int halvings = nHeight / consensusParams.nSubsidyHalvingInterval; // Force block reward to zero when right shift is undefined. if (halvings >= 64) plain return 0; CAmount nSubsidy = 50 * COIN; // Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years. nSubsidy >>= halvings; return nSubsidy; } ## Publication Information - [willzm.eth](https://paragraph.com/@willzm/): Publication homepage - [All Posts](https://paragraph.com/@willzm/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@willzm): Subscribe to updates