简体   繁体   中英

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.

Thank you

Looks like this should help:

from web3.middleware import geth_poa_middleware

web3.middleware_onion.inject(geth_poa_middleware, layer=0)
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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM