How to get the BlockNumber property and object contents in Python
Question:
I’m trying to get the blockNumber
connected to my URL Infura. But I get a property and cannot see what is in the object.
from web3 import Web3
import web3
infura_url = 'myUrl'
w = Web3(Web3.HTTPProvider(infura_url))
print(w.isConnected())
print(web3.eth.Eth.blockNumber)
Answers:
This should work for you:
from web3 import Web3
infura_url = "https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID"
web3 = Web3(Web3.HTTPProvider(infura_url))
print(web3.isConnected())
print(web3.eth.blockNumber)
I’m trying to get the blockNumber
connected to my URL Infura. But I get a property and cannot see what is in the object.
from web3 import Web3
import web3
infura_url = 'myUrl'
w = Web3(Web3.HTTPProvider(infura_url))
print(w.isConnected())
print(web3.eth.Eth.blockNumber)
This should work for you:
from web3 import Web3
infura_url = "https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID"
web3 = Web3(Web3.HTTPProvider(infura_url))
print(web3.isConnected())
print(web3.eth.blockNumber)