go-ethereum/docs/xdc/net/net.md
wit765 8155a2ee7e
docs: refactor jsonrpc api document (#1462)
Co-authored-by: wit <wit765765346@gmail>
2025-09-10 11:56:28 +08:00

997 B

Module net

The net API provides insight about the networking aspect of the client.

Method net_listening

The listening method returns an indication if the node is listening for network connections.

Parameters:

None

Returns:

result: bool, always listening

Example:

curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1001,
  "method": "net_listening"
}' | jq

Method net_peerCount

The peerCount method returns the number of connected peers.

Parameters:

None

Returns:

result: uint

Example:

curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1001,
  "method": "net_peerCount"
}' | jq

Method net_version

The version method returns the devp2p network ID

Parameters:

None

Returns:

result: string

Example:

curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
  "jsonrpc": "2.0",
  "id": 1001,
  "method": "net_version"
}' | jq