For the complete documentation index, see llms.txt. This page is also available as Markdown.

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://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "method": "net_peerCount",
  "params": []
}'
index.js
const axios = require('axios');

const url = 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/';

const payload = {
  jsonrpc: '2.0',
  id: 'getblock.io',
  method: 'net_peerCount',
  params: []
};

axios.post(url, payload, {
  headers: { 'Content-Type': 'application/json' }
})
.then(response => console.log(response.data))
.catch(error => console.error(error));

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?