Okay so let's say I'm looking to get block 1000000
miner reward:
{
difficulty: 12549332509227,
extraData: "0xd783010303844765746887676f312e352e31856c696e7578",
gasLimit: 3141592,
gasUsed: 50244,
hash: "0x8e38b4dbf6b11fcc3b9dee84fb7986e29ca0a02cecd8977c161ff7333329681e",
logsBloom: "0x00000000000000000000000000000000000800000000000000000000000800000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000",
miner: "0x2a65aca4d5fc5b5c859090a6c34d164135398226",
mixHash: "0x92c4129a0ae2361b452a9edeece55c12eceeab866316195e3d87fc1b005b6645",
nonce: "0xcd4c55b941cf9015",
number: 1000000,
parentHash: "0xb4fbadf8ea452b139718e2700dc1135cfc81145031c84b7ab27cd710394f7b38",
receiptsRoot: "0x20e3534540caf16378e6e86a2bf1236d9f876d3218fbc03958e6db1c634b2333",
sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
size: 768,
stateRoot: "0x0e066f3c2297a5cb300593052617d1bca5946f0caa0635fdb1b85ac7e5236f34",
timestamp: 1455404053,
totalDifficulty: 7135202464334937706,
transactions: ["0xea1093d492a1dcb1bef708f771a99a96ff05dcab81ca76c31940300177fcf49f", "0xe9e91f1ee4b56c0df2e9f06c2b8c27c6076195a88a7b8537ba8313d80e6f124e"],
transactionsRoot: "0x65ba887fcb0826f616d01f736c1d2d677bcabde2f7fc25aa91cfbc0b3bad5cb3",
uncles: []
}
Based on this question's answer: How to query the amount of mining reward from a certain block?
You would add the base reward and gas used: 5 + (50244 gwei I think?)
But what I see in etherscan:
https://etherscan.io/block/1000000
5.003614887722 Ether (5 + 0.003614887722 (Tx fees))
I'm very confused, what am I doing wrong?
Best Answer
The issue is that there's not a fixed price per unit of gas. 50,244 gas was used, but how much each user paid for each gas can't be known from just the header.
By examining each transaction in a block through
web3.eth.getTransaction()
andweb3.eth.getTransactionReceipt()
, you can eventually figure who paid what, and then determine the final miner reward.As that linked question notes, you'll also have to add in uncle rewards to get the final total, but I don't know the formula for that off hand.