net_peerCount - Arc RPC Method
Get the number of peers connected to your Arc node. Essential for network health monitoring, peer discovery verification, and load balancer decisions.
Arc RPC endpoint: endpoint URLs, plans and pricing.
Returns the number of peers currently connected to your Arc node.
Why Arc? Build on Circle's stablecoin-native Layer 1 where USDC is the gas token and BFT consensus gives sub-second deterministic finality with USDC as the native gas token, sub-second irreversible finality, an EWMA-smoothed fee market with a 20 Gwei floor, and EIP-7708 Transfer logs for native value movement.
When to Use This Method
net_peerCount is important for payment platforms, stablecoin issuers, exchange and treasury teams, and Solidity developers building on Arc:
- Network Health Monitoring - Verify your node has sufficient peer connections for reliable data propagation
- Peer Discovery Verification - Confirm that peer discovery is working after node startup or network changes
- Load Balancer Decisions - Route traffic to well-connected nodes with healthy peer counts
- Troubleshooting Connectivity - Diagnose networking issues when a node returns stale or missing data
Best Practices
- Low peer count may indicate connectivity or firewall issues; investigate if peers drop unexpectedly
- Minimum healthy peer count varies by network; establish baselines for your specific Arc deployment
- Combine with
eth_syncingfor a complete picture of node health and readiness
Code Examples
Common Use Cases
1. Network Health Monitor
Continuously check peer count and alert when it drops below a threshold:
async function monitorPeers(provider, minPeers = 3, interval = 30000) {
setInterval(async () => {
const peerCountHex = await provider.send('net_peerCount', []);
const peerCount = parseInt(peerCountHex, 16);
if (peerCount === 0) {
console.error('CRITICAL: Node has no peers - network isolated');
} else if (peerCount < minPeers) {
console.warn(`LOW PEERS: ${peerCount} connected (minimum: ${minPeers})`);
} else {
console.log(`Healthy - ${peerCount} peers connected`);
}
}, interval);
}2. Node Readiness Check
Verify a node has enough peers before routing traffic to it:
async function isNodeReady(rpcUrl, minPeers = 5) {
const provider = new JsonRpcProvider(rpcUrl);
const [peerCountHex, syncing] = await Promise.all([
provider.send('net_peerCount', []),
provider.send('eth_syncing', [])
]);
const peerCount = parseInt(peerCountHex, 16);
const isSynced = syncing === false;
const hasEnoughPeers = peerCount >= minPeers;
return {
ready: isSynced && hasEnoughPeers,
peerCount,
syncing: !isSynced
};
}3. Multi-Node Fleet Dashboard
Aggregate peer counts across a fleet of Arc nodes:
import requests
def check_fleet_peers(endpoints):
results = []
for endpoint in endpoints:
try:
response = requests.post(
endpoint,
json={'jsonrpc': '2.0', 'method': 'net_peerCount', 'params': [], 'id': 1},
timeout=5
)
peers = int(response.json()['result'], 16)
results.append({'endpoint': endpoint, 'peers': peers, 'healthy': peers > 0})
except Exception as e:
results.append({'endpoint': endpoint, 'peers': 0, 'healthy': False, 'error': str(e)})
return resultsError Handling
| Error Code | Description | Solution |
|---|---|---|
| -32601 | Method not found | The node may have the net namespace disabled - check node startup flags |
| -32603 | Internal error | Node may be starting up - retry after delay |
| -32005 | Rate limit exceeded | Reduce polling frequency or implement backoff |
Related Methods
net_listening- Check if node is accepting connectionsnet_version- Get the network IDeth_syncing- Check node sync progressweb3_clientVersion- Get node client info
net_listening
Check the legacy net_listening compatibility method on Arc. Public endpoints may return a boolean or an unsupported-method response depending on the client.
web3_clientVersion
Get the client software version of your Arc node. Essential for compatibility checks, fleet monitoring, and debugging client-specific behavior.