[Ethereum] How to calculate mining rewards from the hashrate

block-rewardmathmining

I'm trying to calculate the 24-hour rewards for ethash mining from the numbers at the WhatToMine JSON API.

For example, let’s say I want to calculate the 24-hour mining rewards for 1000 Mh/s ethash: the web GUI says the estimated 24-hour reward is 0.0303 eth,

Meanwhile, the API says:

{
"Ethereum": {
      "id": 151,
      "tag": "ETH",
      "algorithm": "Ethash",
      "block_time": "13.7541",
      "block_reward": 2.5419927147638,
      "block_reward24": 2.45464073212852,
      "last_block": 12928877,
      "difficulty": 7045283557960022,
      "difficulty24": 7052581432317500,
      "nethash": 512231520634576,
      "exchange_rate": 0.060053,
      "exchange_rate24": 0.0600458138222849,
      "exchange_rate_vol": 8376.33269589,
      "exchange_rate_curr": "BTC",
      "market_cap": "$276,000,383,779.77",
      "estimated_rewards": "0.00281",
      "estimated_rewards24": "0.00271",
      "btc_revenue": "0.00016849",
      "btc_revenue24": "0.00016253",
      "profitability": 100,
      "profitability24": 100,
      "lagging": false,
      "timestamp": 1627673948
    }
}

So how do I get 0.0303 from those numbers? I tried

// convert human-readable megahash to raw number of hashes
function MegaHashToHash(i){
    return i*1000000;
}
// convert human-readable megahash-per-second to raw number of hashes-per-24h
function MegaHashTo24h(i){
    return MegaHashToHash(i)*86400; // 86400 = seconds in 24 hours
}
MegaHashTo24h(1000)/(e.difficulty*e.block_reward)

And I get 0.00482437394924059, which is a far cry from the web GUI's calculations of 0.0303, so that calculation must be way off… What's the right way to calculate it?

An interesting observation, doing (MegaHashTo24h(1000)/(e.difficulty))*e.block_reward gives me 0.031173787222154928, which is much closer to the web GUI's 0.0303, but it's still off… And so far I'm just trying random combinations until I get something close to 0.0303.

Best Answer

You could roughly estimate the 24 hr reward as follows:

dailyReward = (your_hashrate / api.nethash) * api.block_reward24 * (6*60*24)

You need to multiply by 6*60*24 to convert the block reward to the total block rewards of a 24hr period, since a new ETH block is mined every 10 seconds. block_reward24 is safer to use than block_reward, since block_reward24 is the 24 hr average block reward. (your_hashrate / api.nethash) is your probability of mining the next block, so on average your daily income would be that probability multiplied by the total rewards of a 24 hr period.

Related Topic