It appears that fee_history must receive an array as the third parameter and it's default None value does not work with some json-rpc nodes.
11 lines
342 B
Python
11 lines
342 B
Python
from web3 import Web3
|
|
|
|
|
|
async def fetch_base_fee_per_gas(w3: Web3, block_number: int) -> int:
|
|
base_fees = await w3.eth.fee_history(1, block_number, [])
|
|
base_fees_per_gas = base_fees["baseFeePerGas"]
|
|
if len(base_fees_per_gas) == 0:
|
|
raise RuntimeError("Unexpected error - no fees returned")
|
|
|
|
return base_fees_per_gas[0]
|