I am using the python web3 library to connect to the Binance Smart Chain at RPC=https://bsc-dataseed.binance.org. Since BSC is a POA chain, I am also using web3.middleware.geth_poa_middleware as follows:
import web3
from web3.middleware import geth_poa_middleware
RPC_URL = "https://bsc-dataseed.binance.org"
myweb3 = web3.Web3(web3.Web3.HTTPProvider(RPC_URL))
myweb3.middleware_onion.inject(geth_poa_middleware,layer=0)
Then later I try to get the latest block (returns an AttributeDict):
block = myweb3.eth.get_block('latest')
The problem is that this block does not have the "baseFeePerGas" key in it. When I try to build a transaction using the web3 library, I get a key error from deep in the library saying keyError: baseFeePerGas. I have printed out the block and I have fields like "gasLimit", "gasUsed" and a list of transactions but no field called "baseFeePerGas".
How do I fix this?