Skip to main content
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();