1

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?

1
  • Were you able to fix this issue?
    – Mikhail
    Commented Apr 1, 2023 at 12:57

2 Answers 2

0

According to the web3.py docs, the method web3.eth.get_block() currently does not support the key baseFeePerGas. However, it seems that BSC transactions must include gasPrice.

See:

https://web3py.readthedocs.io/en/v5/web3.eth.html?highlight=getBlock#web3.eth.Eth.getBlock

https://web3py.readthedocs.io/en/latest/web3.eth.html

0

Include gasPrice as a parameter when sending transactions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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