Net API

The web3.net object exposes methods to interact with the RPC APIs under the net_ namespace.

Properties

The following properties are available on the web3.net namespace.

web3.net.listening()
..py:property::
  • Delegates to net_listening RPC method

Returns true if client is actively listening for network connections.

>>> web3.net.listening
True
web3.net.peer_count()
..py:property::
  • Delegates to net_peerCount RPC method

Returns number of peers currently connected to the client.

>>> web3.net.peer_count
1
web3.net.version()
..py:property::
  • Delegates to net_version RPC Method

Returns the current network id.

>>> web3.net.version
'8996'