githubEdit

net_peerCount - Celo

Example code for the net_peerCount JSON-RPC method. Complete guide on how to use net_peerCount JSON-RPC in GetBlock Web3 documentation.

This method returns the number of peers currently connected to the Celo node. This is useful for monitoring network connectivity.

Parameters

  • None

Request Example

curl
curl -X POST https://go.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "method": "net_peerCount",
  "params": []
}'

Response Example

response.json
{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "result": "0x19"
}

Response Definition

Field
Type
Description

result

string

Number of connected peers (hex)

Use Cases

  • Monitor network connectivity

  • Assess node health

  • Debug connection issues

Error Handling

Error Code
Description

-32603

Internal error

Last updated

Was this helpful?