CRYPTO NEWS

Saving the planet could be blockchain’s killer app

“Putting Paris Agreement carbon markets on Ethereum and connecting the national carbon accounts of the world, is blockchain’s killer app.”

How to get miner tips via json rpc

I’d like to make a statistic about the average mining tip, but I haven’t found an easy/fast way to get this information from my full node. I can get the full block via RPC but it doesn’t seem to contain enough information. In particular the transactions have the information about the actual used gasPrice, but::Listen

I’d like to make a statistic about the average mining tip, but I haven’t found an easy/fast way to get this information from my full node. I can get the full block via RPC but it doesn’t seem to contain enough information. In particular the transactions have the information about the actual used gasPrice, but no gasUsed field. The block itself has only the gasUsed for all transaction together which doesn’t help either.

I can get gasUsed for each transaction via getTransactionReceipt but that is slow. My current script (see below) runs at 1-1.5 blocks/sec.

#!/usr/bin/env python3  import requests import json import sys  # get miner tips for blknr.  This only works with post-London blocks. def main(blknr):     url = "http://localhost:8545/"     s = requests.Session()     idctr = 0     payload = { "method":"eth_getBlockByNumber",                 "params":[("0x%x" % blknr), True],                 "id": idctr,                 "jsonrpc": "2.0" }     idctr += 1     response = s.post(url, json=payload).json()     result = response["result"]     transactions = result["transactions"]     basefee = int(result["baseFeePerGas"],0)     totalfee = 0     totalgas = 0     for tx in transactions:         gasPrice = int(tx["gasPrice"],0)         txid = tx["hash"]         payload = { "method":"eth_getTransactionReceipt",                     "params":[txid],                     "id": idctr,                     "jsonrpc": "2.0" }         idctr +=1         txresult = s.post(url, json=payload).json()["result"]         gasUsed = int(txresult["gasUsed"],0)         totalfee += gasUsed * gasPrice         totalgas += gasUsed      assert blknr == int(result["number"],0)     assert totalgas == int(result["gasUsed"],0)     timestamp = int(result["timestamp"],0)     miner = result["miner"]     burned = basefee * totalgas     minerTip = totalfee - burned 

So is there a simpler and faster way to get the miner tips per block that I’m overlooking?

Saving the planet could be blockchain’s killer app

Shopping cart
There are no products in the cart!
Continue shopping
0