Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web3 ExtraDataLength Error on the Binance Smart Chain using python

I'm trying to pull the transactions that took place on a specific block, and I get stuck here:

from web3 import Web3

bsc = "https://bsc-dataseed.binance.org/"
web3 = Web3(Web3.HTTPProvider(bsc))

block = web3.eth.get_block('latest')

web3.exceptions.ExtraDataLengthError: The field extraData is 97 bytes, but should be 32. It is quite likely that you are connected to a POA chain. Refer to http://web3py.readthedocs.io/en/stable/middleware.html#geth-style-proof-of-authority for more details.

I want to get the transactions that a certain wallet address was involved in, and I have no idea why web3 isn't letting me pull that from the bsc node.

like image 535
swaggy pete Avatar asked Nov 04 '25 16:11

swaggy pete


1 Answers

from web3 import Web3
from web3.middleware import geth_poa_middleware

web3 = Web3(Web3.HTTPProvider('127.0.0.1:100500'))
web3.middleware_onion.inject(geth_poa_middleware, layer=0)
like image 99
Михаил Чеботарев Avatar answered Nov 07 '25 11:11

Михаил Чеботарев



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!