# Need specific instructions on using formula to calculate Monero's current block reward

Building my own php-based monero profit calculator for fun.

However, setting a static variable for "block_reward" would be very bad, and become less accurate as time goes by.

I've looked at this thread here: What is the mining reward equation?

I've also looked at the whitepages here: https://cryptonote.org/whitepaper.pdf Page 13 specifically

I'll post their high-level equation first:

``````To ensure the smoothness of the emission process we use the following
formula for block rewards:
MSupply = 2^64 − 1 atomic units
BaseReward = (MSupply − A) >> 18,
where A is amount of previously generated coins.
``````

Here's the laymen's version of the formula:

``````The Monero block reward = (M - A) * 2^-20 * 10^-12
Where A = current circulation. (NOTE:Assuming M = total supply)
``````

Using this "laymen's" formula with current supply and circulation as of RIGHT now Doing this on a scientific calculator

``````(18,132,000 - 14,952,626) * 2^-20 *10^-12
(3179374) * (0.00000095367431640625) * (0.000000000001)
3.0320873260498046875 * (0.000000000001)
0.0000000000030320873260498046875     // Final Solution
``````

What am I missing? That's clearly NOT the block reward

Current block reward is saying 6.6 XMR Found on: https://whattomine.com/coins/101-xmr-cryptonight

I went on Freenode IRC #monero-dev and got an answer to Atomic Units

An Atomic Unit, for Monero, = 1e-12 or .000000000001

That's eleven zeros before the 1

Here's the php code I used to calculate this for anyone that would like to use it

``````//Simple Public Get API
\$url = "https://moneroblocks.info/api/get_stats";
// Make Request
\$info = file_get_contents(\$url);
// Digest JSON into a php array (FLAG 2)
\$info = json_decode(\$info,2);

\$total_circulation = \$info['total_emission'];

// Calclulate total supply, this is taken directly from cryptonote man pages
// https://cryptonote.org/whitepaper.pdf  ATOMIC  UNIT for monero = 1e12
\$total_supply = pow(2,64) * 1e-12;
\$base_reward = (\$total_supply - \$total_circulation) >> 20;

\$next_step = \$base_reward * 1e-12;
// Multiply by 2
\$actual_reward = \$next_step * 2;
``````

Hope this helps someone!

• This is potentially just conjecture, but take note: Someone in the #monero-dev IRC had mentioned that the bitshift >> should actually be 20 not 18. Saying this might actually be closer to bytecoin's formula. All I know is it's returning a nearly identical value as the monero blockchain explorers – shamelessApathy Aug 25 '17 at 23:01
• >> 20 instead of >> 18 makes the result 4 times smaller. Instead of the guessed /2, multiply by 2 (twice as few blocks means twice as much reward per block to keep the emission curve). You then end up with the right value. Magic. – user36303 Aug 26 '17 at 1:04
• Thank you for this. Chatrooms aren't always the easiest to decipher an incomplete sentence into a working answer haha. I actually didn't really know what a bit shift was until today :-D , part of the reason I love learning crypto coding, it forces me to learn new things that I'd generally never need to do writing web based php – shamelessApathy Aug 26 '17 at 2:48