Reputation: 11
trying to use web3.py V5.31.1 with infura as a websocketprovider, but no methods seem to work.
The only method that works is w3.eth.chainId
my code:
from web3 import Web3
import web3
w3 = Web3(Web3.WebsocketProvider('wss://mainnet.infura.io/ws/v3/myapikey'))
print(w3.eth.chainId)
#w3.clientVersion --#doesnt work
#w3.is_connected() --#doesnt work
try:
print(web3.eth.get_block('latest'))
except:
print(web3.eth.getBlock('latest'))
error:
AttributeError: module 'web3.eth' has no attribute 'getBlock'
AttributeError: module 'web3.eth' has no attribute 'get_block'
any ideas why this could be happening?
Upvotes: 0
Views: 402
Reputation: 83768
You are confusing w3
instance and web3
module.
Please use:
print(w3.eth.get_block('latest'))
Upvotes: 2