curl --request POST \
--url https://fantom-mainnet.core.chainstack.com/4ab982aa70a7baead515ffdb5915df3f \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "net_peerCount",
"params": []
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}
curl --request POST \
--url https://fantom-mainnet.core.chainstack.com/4ab982aa70a7baead515ffdb5915df3f \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "net_peerCount",
"params": []
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}
none
quantity
— an integer value indicating the current number of peers connected to the nodenet_peerCount
code examplesconst { Web3 } = require("web3");
const NODE_URL = "CHAINSTACK_NODE_URL";
const web3 = new Web3(NODE_URL);
async function getPeers() {
const peers = await web3.eth.net.getPeerCount()
console.log(peers);
}
getPeers();
net_peerCount
method is to monitor the number of peers connected to a node and take some action if the number drops below a certain threshold. For example, a developer might want to send a notification to check the node if the peer count is low for more than 10 minutes.The number of peers connected to the client.
The response is of type object
.
Was this page helpful?