Documentation Index
Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
Use this file to discover all available pages before exploring further.
NodeInfo
Type-safe structure for Ethereum node information returned by admin_nodeInfo RPC method.
Overview
NodeInfo represents metadata about a local Ethereum node, including network identity, protocol information, chain state, and listening ports. This data is returned by the admin_nodeInfo RPC method available in Geth and compatible clients.
Quick Start
import * as NodeInfo from '@tevm/voltaire/NodeInfo'
// Parse node info from RPC response
const nodeInfo = NodeInfo.from({
enode: "enode://abc123...@192.168.1.1:30303",
id: "abc123...",
ip: "192.168.1.1",
listenAddr: "192.168.1.1:30303",
name: "Geth/v1.13.0-stable/linux-amd64/go1.21.0",
ports: {
discovery: 30303,
listener: 30303
},
protocols: {
eth: {
network: 1,
difficulty: 58750003716598352816469n,
genesis: "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3",
head: "0x1234..."
}
}
})
// Get protocol info
const ethProtocol = NodeInfo.getProtocol(nodeInfo, "eth")
console.log(ethProtocol?.network) // 1
import * as NodeInfo from '@tevm/voltaire/NodeInfo'
async function getNodeInfo(rpcUrl: string) {
const response = await fetch(rpcUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'admin_nodeInfo',
params: [],
id: 1
})
})
const { result } = await response.json()
return NodeInfo.from(result)
}
const nodeInfo = await getNodeInfo('http://localhost:8545')
console.log(nodeInfo.name) // "Geth/v1.13.0-stable/..."
Type Definition
type NodeInfoType = {
/** Enode URL of the node */
readonly enode: PeerIdType
/** Node ID (hex-encoded public key) */
readonly id: string
/** External IP address */
readonly ip: string
/** Listen address (IP:PORT) */
readonly listenAddr: string
/** Client identifier */
readonly name: string
/** Network ports */
readonly ports: {
/** UDP discovery port */
readonly discovery: number
/** TCP listener port */
readonly listener: number
}
/** Protocol-specific information */
readonly protocols: {
/** Ethereum protocol info */
readonly eth?: {
readonly network: NetworkIdType
readonly difficulty: BrandedUint
readonly genesis: BlockHashType
readonly head: BlockHashType
readonly config: Record<string, unknown>
}
readonly [protocol: string]: unknown
}
}
API Reference
Constructors
import * as NodeInfo from '@tevm/voltaire/NodeInfo'
// From RPC response object
const nodeInfo = NodeInfo.from(rpcResponse)
Methods
import * as NodeInfo from '@tevm/voltaire/NodeInfo'
const nodeInfo = NodeInfo.from(data)
// Get protocol-specific information
const ethInfo = NodeInfo.getProtocol(nodeInfo, "eth")
const snapInfo = NodeInfo.getProtocol(nodeInfo, "snap")
Node Properties
Enode URL
The enode field contains the full enode URL for connecting to this node:
nodeInfo.enode
// "enode://abc123...@192.168.1.1:30303?discport=30301"
Client Name
The name field identifies the client software:
nodeInfo.name
// "Geth/v1.13.0-stable/linux-amd64/go1.21.0"
// "Nethermind/v1.21.0/linux-x64/dotnet7.0.11"
// "Erigon/v2.55.0/linux-amd64/go1.21.0"
Network Ports
nodeInfo.ports.discovery // UDP port for peer discovery (default: 30303)
nodeInfo.ports.listener // TCP port for RLPx connections (default: 30303)
const eth = nodeInfo.protocols.eth
eth?.network // Network ID (1 for mainnet)
eth?.difficulty // Total chain difficulty
eth?.genesis // Genesis block hash
eth?.head // Current head block hash
eth?.config // Chain configuration
Use Cases
Node Monitoring
import * as NodeInfo from '@tevm/voltaire/NodeInfo'
async function monitorNode(rpcUrl: string) {
const response = await fetch(rpcUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'admin_nodeInfo',
params: [],
id: 1
})
})
const { result } = await response.json()
const nodeInfo = NodeInfo.from(result)
return {
client: nodeInfo.name,
ip: nodeInfo.ip,
enode: nodeInfo.enode,
network: nodeInfo.protocols.eth?.network,
headBlock: nodeInfo.protocols.eth?.head
}
}
Client Version Check
import * as NodeInfo from '@tevm/voltaire/NodeInfo'
function parseClientVersion(nodeInfo: NodeInfoType) {
const name = nodeInfo.name
const parts = name.split('/')
return {
client: parts[0], // "Geth", "Nethermind", etc.
version: parts[1], // "v1.13.0-stable"
platform: parts[2], // "linux-amd64"
runtime: parts[3] // "go1.21.0"
}
}
function isGeth(nodeInfo: NodeInfoType): boolean {
return nodeInfo.name.startsWith('Geth/')
}
function meetsMinVersion(nodeInfo: NodeInfoType, minVersion: string): boolean {
const version = parseClientVersion(nodeInfo).version
// Version comparison logic
return version >= minVersion
}
Multi-Protocol Support Check
import * as NodeInfo from '@tevm/voltaire/NodeInfo'
function getSupportedProtocols(nodeInfo: NodeInfoType): string[] {
return Object.keys(nodeInfo.protocols)
}
function supportsSnap(nodeInfo: NodeInfoType): boolean {
return 'snap' in nodeInfo.protocols
}
function supportsLes(nodeInfo: NodeInfoType): boolean {
return 'les' in nodeInfo.protocols
}
References