I want to write a script to analyze mining rewards. What is the best way to query for the amount of mining rewards of a certain block? It seems possible to query the address of the lucky miner:


Then I can somehow delve into the account and pick the transaction at certain block. Is this the best way? Or do you know shortcuts? And how to do it?

2 Answers 2


"Then I can somehow delve into the account and pick the transaction at certain block."

Mining rewards aren't transactions, so you can't query them in the usual way. As per this previous answer:

There are no inputs and outputs in Ethereum, just state changes and balances. Therefore, mining rewards don't have a transaction hash since they are not a transaction.

You'll either need to calculate the reward yourself, or use somebody else's API.

Calculating the reward yourself

The algorithm for calculating the reward - as stated on the Mining wiki page - is as follows:

The successful PoW miner of the winning block receives:

  • A static block reward for the 'winning' block, consisting of exactly 5.0 Ether
  • All of the gas expended within the block, that is, all the gas consumed by the execution of all the transactions in the block submitted by the winning miner is compensated for by the senders. The gascost incurred is credited to the miner's account as part of the consensus protocoll. Over time, it's expected these will dwarf the static block reward.
  • An extra reward for including Uncles as part of the block, in the form of an extra 1/32 per Uncle included

The data required for the second and third parts can be queried from the block using:

  • web3.eth.getBlock(<block>).gasUsed
  • web3.eth.getBlock(<block>).uncles (Note: The reward per uncle is /32 of the static reward, i.e. 5 / 32.)

Using someone else's API

Etherscan is one of the block explorers that includes details of the reward for a given block (see here for an example). Details of their APIs can be found either on their site, or, for Python bindings, on this GitHub page. (I haven't checked that these return the reward details, so YMMV.)

EDIT : The static reward is now 3.0 Ether

  • It would be web3.eth.getBlock(<block>).gasUsed or web3.eth.getBlock(<block>).cumulativeGasUsed?
    – AdrianClv
    Aug 18, 2016 at 14:11
  • 1
    Just .gasUsed. Have a look at the return values for eth_getBlockByHash - you'll see that .gasUsed is the total for that block. .cumulativeGasUsed is when you use one of the transaction APIs (not block-level APIs) and you want the total for the block in which the transaction resides. Aug 18, 2016 at 14:20
  • Thank you, you are right. I was mixing the getBlock() function with getTransactionReceipt() for some reason. And for the reward from uncles, then it would be enough to do numberOfUncles*5/32? Reading the wiki page, it also says: "Uncles included in a block formed by the successful PoW miner receive 7/8 of the static block reward = 4.375 ether A maximum of 2 uncles allowed per block."
    – AdrianClv
    Aug 18, 2016 at 14:52

In addition to the Richard's answer, in terms of API, Reward for the block can be also fetched from trace_block JSON RPC API method directly from OpenEthereum/NethmindETH/Erigon RPC node, if such API is enabled.

It should be in "result[i]" => "action" => "value" of the i element from the response which has "type": "reward". It should be noted, there could be multiple elements with reward type, for instance if Block reward contract is configured.

An example of response from trace_block API.

    "jsonrpc": "2.0",
    "id": 1,
    "result": [
        "action": {
            "author": "0x646db8ffc21e7ddc2b6327448dd9fa560df41087",
            "rewardType": "block",
            "value": "0x1bc16d674ec80000"
        "blockHash": "0xdcd887d9301d279c4754df78c6b69f26d2839b12201b0b337bc2512d015682b5",
        "blockNumber": 14621621,
        "result": null,
        "subtraces": 0,
        "traceAddress": [],
        "type": "reward"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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