I have the following formula which can be used to estimate someones mining profits for ethereum:

(UserHashMh * 1e6 / ((difficultyTH / BlockTimeSec)*1000*1e9))*((60/ BlockTimeSec)*BlockReward)*(60*24*30)*(EthPrice)

I can quite easily get the data by going to websites and pulling it that way, but im looking to design my program to not be dependent on a third-party to produce these estimates. I have access to a full node with full IPC/RPC access. Ideally im looking to be able to calculate this using RPC or IPC calls with my local node and not have to go to a third party. The only calls I'm anticipating having to go to a third-party are for the eth price, and users hash rate.

1 Answer 1


Here are some ideas.


A couple of options, best described in previous answers. Might depend on which mining software you're using, or if you're part of a pool.


Use web3.eth.getBlock(blockNumber).difficulty.


Using web3, subtract the timestamp of the previous block from the latest block:

web3.eth.getBlock(blockNumber).timestamp - web3.eth.getBlock(blockNumber - 1).timestamp

(Is there a better way to do this?)


Currently set to 3 (as per consensus.go). I think the formula is set up to disregard any transaction fees or uncles. I suppose you could change the formula to include these by looking at how full blocks currently are on average, together with the average gas price, while also including the current average uncle rate. Might start to get tricky to calculate though.


This will depend on the market (e.g. exchange) you look at. It would make sense to use a price that is relevant to you. (e.g. If you're in the US, don't use the prices on a Japanese exchange.) If you want an aggregate price, then something like CoinMarketCap's API would work:


This returns a JSON object, so just pull out the field(s) you want.

  • I can't award the bounty for 22 more hours apparently, but when I can it will be given. Thank you!
    – hextet
    Apr 8, 2018 at 8:54
  • No problem - happy to help :-) Apr 8, 2018 at 8:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.