1

I am looking at the infura documentation and no matter what method I am trying to authenticate my project id I am getting errors such as the one displayed below or 404 errors. Has anyone had the same issue and found a solution? I am trying to connect to the eth mainnet.

(venv) C:\Users\name\PycharmProjects\UniswapQuery>curl --user :https://mainnet.infura.io/v3/[my project id]
curl: no URL specified!
curl: try 'curl --help' for more information

This is the python code that refers to the infura network:

infura_url = 'https://mainnet.infura.io/v3/[my project id]'
web3 = Web3(Web3.HTTPProvider(infura_url))

1 Answer 1

1

Usually you would use the built-in Infura mainnet object:

At the command line:

$ export WEB3_INFURA_PROJECT_ID=<project id>
$ export WEB3_INFURA_API_SECRET=<secret>

Then in Python:

>>> from web3.auto.infura.mainnet import w3
>>> w3.isConnected()
True
>>> w3.eth.block_number
12642083
3
  • Unfortunately the command line code gives me errors and the 'from web3.auto.infura.mainnet import w3' is saying that it isnt recognized
    – Reece
    Jun 16, 2021 at 7:15
  • You have likely wrong Web3.py version Jun 16, 2021 at 9:01
  • @Reece What is the exact error you are getting when you try that import? Jun 29, 2021 at 19:15

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.