Skip to main content

Overview

The net namespace provides methods for querying network connectivity and peer information.

Methods

net_version

Returns the current network ID.
curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}' \
  https://rpc.viction.xyz
result
string
Network ID as a string
  • “88” for Viction mainnet
  • “89” for Viction testnet
Example Response:
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "88"
}
The network ID is returned as a decimal string, not hexadecimal. This differs from eth_chainId which returns hexadecimal.

net_listening

Returns true if the client is actively listening for network connections.
curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":1}' \
  https://rpc.viction.xyz
result
boolean
true if listening, false otherwise
Example Response:
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": true
}

net_peerCount

Returns the number of peers currently connected to the client.
curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' \
  https://rpc.viction.xyz
result
string
Number of connected peers as a hexadecimal string
Example Response:
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x19"
}
In the example above, 0x19 (25 in decimal) peers are connected.

Network Identifiers

Viction Mainnet

Viction Testnet


Usage Examples

JavaScript (Web3.js)

const Web3 = require('web3');
const web3 = new Web3('https://rpc.viction.xyz');

// Get network version
web3.eth.net.getId()
  .then(id => console.log('Network ID:', id));

// Check if node is listening
web3.eth.net.isListening()
  .then(listening => console.log('Listening:', listening));

// Get peer count
web3.eth.net.getPeerCount()
  .then(count => console.log('Peer count:', count));

JavaScript (Ethers.js)

const { JsonRpcProvider } = require('ethers');
const provider = new JsonRpcProvider('https://rpc.viction.xyz');

// Get network
provider.getNetwork()
  .then(network => {
    console.log('Network ID:', network.chainId);
  });

// Check peer count
provider.send('net_peerCount', [])
  .then(count => console.log('Peer count:', parseInt(count, 16)));

Python (Web3.py)

from web3 import Web3

w3 = Web3(Web3.HTTPProvider('https://rpc.viction.xyz'))

# Get network version
network_id = w3.net.version
print(f'Network ID: {network_id}')

# Check if node is listening
listening = w3.net.listening
print(f'Listening: {listening}')

# Get peer count
peer_count = w3.net.peer_count
print(f'Peer count: {peer_count}')

Network Diagnostics

These methods are useful for:

Network Detection

Identify which Viction network (mainnet/testnet) you’re connected to

Connection Health

Verify your node is actively listening for connections

Peer Monitoring

Monitor the number of connected peers for network health

Sync Verification

Ensure your node is properly connected to the network

Troubleshooting

Low Peer Count

If net_peerCount returns a very low number (less than 5):
  1. Check firewall settings - ensure P2P port (default 30303) is open
  2. Verify network connectivity
  3. Check if bootnodes are configured correctly
  4. Ensure sufficient disk space and system resources

Not Listening

If net_listening returns false:
  1. Check if the node is fully started
  2. Verify the P2P port configuration
  3. Check for port conflicts
  4. Review node logs for errors

Network Mismatch

If net_version returns unexpected value:
  1. Verify you’re connecting to the correct RPC endpoint
  2. Check if the node is syncing the intended network
  3. Review genesis configuration for custom networks

Build docs developers (and LLMs) love