Issue with python's web3 module: why is web3.isConnected() always returning false?

Viewed 23

I'm trying to get acquainted with python's web3 class, and I cannot seem to get connected to infura's node using my API. The isConnected() function always returns false, no matter what.

from web3 import Web3, eth

infura_url = 'https://mainnet.infura.io/v3/' + my_api_key
w3 = Web3(HTTPProvider(infura_url))
print (w3.isConnected())

Always returns false. And if I can't connect to the ethereum network, I can't run fucntions on contracts etc. It's a problem :(

1 Answers

There is two possiblity

one :
you need to check api key

two :
maybe the chain you got it doesnt provide method name start as eth
web3 default method naming as eth, every method start like this eth_transfer
so when you wanna check this possiblity, you can call method like print(w3.isConnected())
go infura dashboard and check your requests volumn.
if your request was accepted but respond as false, it might be means that method name start different

Related