system_localListenAddresses - JSON-RPC Method
Description#
Returns the local libp2p multiaddresses that the Moonriver node is actively listening on for peer-to-peer connections. This method provides essential network configuration information including IP addresses, ports, protocols, and peer IDs. The multiaddress format follows the libp2p specification and includes all network interfaces and transports the node has configured for incoming connections.
Parameters#
This method does not require any parameters.
Returns#
| Field | Type | Description |
|---|---|---|
result | array | Array of multiaddress strings in libp2p format |
Each multiaddress string contains:
- IP protocol (ip4, ip6, dns)
- IP address or hostname
- Transport protocol (tcp, ws, wss)
- Port number
- Peer ID (p2p component)
Use Cases#
- Network Debugging: Diagnose peer-to-peer connectivity issues and firewall configurations
- Node Configuration Verification: Confirm the node is listening on expected interfaces and ports
- Security Auditing: Verify that nodes are not exposing unnecessary network interfaces
- Infrastructure Documentation: Document network topology in multi-node deployments
- Connection Testing: Obtain connection strings for manual peer connectivity testing
- Monitoring Tools: Track which network interfaces are active for operational visibility
Request Example#
curl -s https://api-moonriver.n.dwellir.com/YOUR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "system_localListenAddresses",
"params": []
}'
Response Example#
{
"jsonrpc": "2.0",
"result": [
"/ip4/127.0.0.1/tcp/30333/ws/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp",
"/ip6/::1/tcp/30333/ws/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp",
"/ip4/192.168.1.10/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp"
],
"id": 1
}
Code Examples#
JavaScript (polkadot.js)#
import { ApiPromise, WsProvider } from '@polkadot/api';
const api = await ApiPromise.create({
provider: new WsProvider('wss://api-moonriver.n.dwellir.com/YOUR_API_KEY')
});
const addresses = await api.rpc.system.localListenAddresses();
console.log('Node listening on:');
addresses.forEach((addr) => console.log(` ${addr.toString()}`));
Python#
import requests
import json
def get_listen_addresses():
url = "https://api-moonriver.n.dwellir.com/YOUR_API_KEY"
payload = {
"jsonrpc": "2.0",
"method": "system_localListenAddresses",
"params": [],
"id": 1
}
response = requests.post(url, json=payload)
return response.json()["result"]
addresses = get_listen_addresses()
print("Node listening addresses:")
for addr in addresses:
print(f" {addr}")
# Parse multiaddress components
for addr in addresses:
parts = addr.split('/')
protocol = parts[1]
address = parts[2]
transport = parts[3] if len(parts) > 3 else "N/A"
print(f"Protocol: {protocol}, Address: {address}, Transport: {transport}")
Node.js (fetch)#
async function getNetworkInfo() {
const response = await fetch('https://api-moonriver.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'system_localListenAddresses',
params: [],
id: 1
})
});
const data = await response.json();
return data.result;
}
const addresses = await getNetworkInfo();
console.log(`Node listening on ${addresses.length} addresses:`);
addresses.forEach(addr => console.log(` ${addr}`));
Best Practices#
- Use this method during node setup to verify correct network configuration
- Check listen addresses match your intended network exposure (localhost vs. public)
- Include listen addresses in node health check scripts
- Document listen addresses for troubleshooting network connectivity issues
- Verify firewall rules allow connections to the listening ports
Related Methods#
system_health- Get overall node health