Skip to main content
POST
net_peerCount
curl --request POST \
  --url https://rpc.testnet.tempo.xyz/ \
  --header 'Content-Type: application/json' \
  --data '
{
  "jsonrpc": "2.0",
  "method": "net_peerCount",
  "params": [],
  "id": 1
}
'
{
  "jsonrpc": "<string>",
  "id": 123,
  "result": "<string>"
}
Tempo API method that returns the number of peers currently connected to the client.

Parameters

None.

Response

  • result — the number of connected peers encoded as hexadecimal

net_peerCount code examples

const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);

const getPeerCount = async () => {
    const peerCount = await provider.send("net_peerCount", []);
    console.log(`Connected peers: ${parseInt(peerCount, 16)}`);
  };

getPeerCount();

Body

application/json
jsonrpc
string
default:2.0
method
string
default:net_peerCount
params
any[]
id
integer
default:1

Response

200 - application/json

The peer count

jsonrpc
string
id
integer
result
string

Number of connected peers encoded as hexadecimal