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

net_peerCount - BSC

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

This method returns the number of peers currently connected to the client on the BNB Smart Chain network.

Parameters

  • None

Request Example

cURL
curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "net_peerCount",
    "params": [],
    "id": "getblock.io"
}'
JavaScript (Axios)
const axios = require('axios');

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

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

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

Response Example

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

Response Parameters

Parameter
Type
Description

result

string

Peer count in hex (0x19 = 25)

Use Cases

  • Monitor node connectivity

  • Check network health

  • Debug connection issues

Error Handling

-32603

Internal error

SDK Integration

Last updated

Was this helpful?