For the complete documentation index, see llms.txt. This page is also available as Markdown.

net_listening - Somnia

Example code for the net_listening JSON-RPC method. Complete guide on how to use net_listening JSON-RPC in GetBlock Web3 documentation

This method returns true if the client is actively listening for network connections on the Somnia network.

Parameters

  • None

Request Example

cURL
curl -X POST https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/ \
-H "Content-Type: application/json" \
-d '{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "method": "net_listening",
  "params": []
}'
request.js
const axios = require('axios');

const payload = {
  jsonrpc: '2.0',
  id: 'getblock.io',
  method: 'net_listening',
  params: []
};

axios.post('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', payload)
.then(response => console.log(response.data));
request.py
import requests

payload = {
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "method": "net_listening",
    "params": []
}

response = requests.post("https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/", json=payload)
print(response.json())

Response Example

response.json
{
  "jsonrpc": "2.0",
  "id": "getblock.io",
  "result": true
}

Use Cases

  • Node health checks

  • Connection validation

  • Monitoring node status

Last updated

Was this helpful?