0

I am trying to get the number of peers that my node is connected to.

I am connected to INFURA endpoint:

from web3 import Web3
w3 = Web3(
    Web3.HTTPProvider(("https://mainnet.infura.io/v3....."))
)

print(w3.geth.admin.peers()) // Gives error

I receive following error:

ValueError: {'code': -32601, 'message': 'The method admin_peers does not exist/is not available'}

Am I doing something wrong?

I made sure I am connected by:

>>> w3.isConnected()
True

1 Answer 1

0

Following line should solve your issue:

print(w3.net.peerCount)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.