Docs
Supported ChainsTempoJSON-RPC APINetwork Methods

net_peerCount - Tempo RPC Method

Get the number of peers connected to your Tempo node. Essential for network health monitoring, peer discovery verification, and load balancer decisions.

Returns the number of peers currently connected to your Tempo node.

Why Tempo? Build on a payments-first EVM chain with deterministic settlement and stablecoin-native fees with no native gas token, fees denominated in supported USD stablecoins, and full EVM RPC compatibility.

When to Use This Method

net_peerCount is important for payment application developers, wallet teams, stablecoin issuers, and treasury automation builders:

  • 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

Request Parameters

Request

This method accepts no parameters.

Response Body

Response
resultQUANTITY

Hexadecimal string representing the number of connected peers

Error Responses

Errors
Error Response-32601

Code Examples

Bash
curl -X POST https://api-tempo-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "net_peerCount",
    "params": [],
    "id": 1
  }'

Common Use Cases

1. Network Health Monitor

Continuously check peer count and alert when it drops below a threshold:

JavaScript
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:

JavaScript
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 Tempo nodes:

Python
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 results

Error Handling

Error CodeDescriptionSolution
-32601Method not foundThe node may have the net namespace disabled — check node startup flags
-32603Internal errorNode may be starting up — retry after delay
-32005Rate limit exceededReduce polling frequency or implement backoff