net_peerCount
Returns number of peers currently connected to Astar client.
Parameters#
This method accepts no parameters.
Request#
{
"jsonrpc": "2.0",
"method": "net_peerCount",
"params": [],
"id": 1
}
Returns#
| Type | Description |
|---|---|
QUANTITY | Number of connected peers (hexadecimal) |
Code Examples#
- cURL
- JavaScript
curl -X POST https://api-astar.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "net_peerCount",
"params": [],
"id": 1
}'
import { JsonRpcProvider } from 'ethers';
const provider = new JsonRpcProvider('https://api-astar.n.dwellir.com/YOUR_API_KEY');
const peerCount = await provider.send('net_peerCount', []);
console.log('Peer count:', parseInt(peerCount, 16));
Related Methods#
net_listening- Check if listening