Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/NodeInfo

primitives/NodeInfo

Type Aliases

NodeInfoType

NodeInfoType = object
Defined in: src/primitives/NodeInfo/NodeInfoType.ts:17 Node information structure from admin_nodeInfo RPC method Contains metadata about the local Ethereum node including:
  • Network identity (enode, ID, IP)
  • Protocol information
  • Chain state (genesis, head, difficulty)
  • Listening ports

See

https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-admin#admin-nodeinfo

Properties

enode
readonly enode: PeerIdType
Defined in: src/primitives/NodeInfo/NodeInfoType.ts:19 Enode URL of the node
id
readonly id: string
Defined in: src/primitives/NodeInfo/NodeInfoType.ts:21 Node ID (hex-encoded public key)
ip
readonly ip: string
Defined in: src/primitives/NodeInfo/NodeInfoType.ts:23 External IP address
listenAddr
readonly listenAddr: string
Defined in: src/primitives/NodeInfo/NodeInfoType.ts:25 Listen address (IP:PORT)
name
readonly name: string
Defined in: src/primitives/NodeInfo/NodeInfoType.ts:27 Client identifier (e.g., “Geth/v1.10.26-stable/linux-amd64/go1.19.5”)
ports
readonly ports: object
Defined in: src/primitives/NodeInfo/NodeInfoType.ts:29 Network ports
discovery
readonly discovery: number
UDP discovery port
listener
readonly listener: number
TCP listener port
protocols
readonly protocols: object
Defined in: src/primitives/NodeInfo/NodeInfoType.ts:36 Protocol-specific information
Index Signature
[protocol: string]: unknown Other protocols (snap, les, etc.)
eth?
readonly optional eth: object
Ethereum protocol info (if supported)
eth.config
readonly config: Record<string, unknown>
Chain configuration
eth.difficulty
readonly difficulty: BrandedUint
Total difficulty of the chain
eth.genesis
readonly genesis: BlockHashType
Genesis block hash
eth.head
readonly head: BlockHashType
Current head block hash
eth.network
readonly network: NetworkIdType
Network ID

Variables

NodeInfo

const NodeInfo: object
Defined in: src/primitives/NodeInfo/index.ts:22

Type Declaration

from()
from: (value) => NodeInfoType
Create NodeInfo from RPC response object
Parameters
value
any Node info object from admin_nodeInfo
Returns
NodeInfoType Node information
Throws
If value is not a valid node info object
Example
import * as NodeInfo from './primitives/NodeInfo/index.js';
const nodeInfo = NodeInfo.from(rpcResponse);
console.log(nodeInfo.name);     // "Geth/v1.10.26-stable"
console.log(nodeInfo.protocols.eth?.network); // NetworkId
getProtocol()
getProtocol: (nodeInfo, protocolName) => unknown
Parameters
nodeInfo
any
protocolName
string
Returns
unknown

Functions

_getProtocol()

_getProtocol(this, protocolName): unknown
Defined in: src/primitives/NodeInfo/getProtocol.js:16 Get protocol information by name

Parameters

this
NodeInfoType
protocolName
string Protocol name (e.g., “eth”, “snap”)

Returns

unknown Protocol information or undefined

Example

import * as NodeInfo from './primitives/NodeInfo/index.js';
const nodeInfo = NodeInfo.from(rpcResponse);
const ethProtocol = NodeInfo._getProtocol.call(nodeInfo, "eth");
console.log(ethProtocol?.network); // NetworkId

from()

from(value): NodeInfoType
Defined in: src/primitives/NodeInfo/from.js:23 Create NodeInfo from RPC response object

Parameters

value
any Node info object from admin_nodeInfo

Returns

NodeInfoType Node information

Throws

If value is not a valid node info object

Example

import * as NodeInfo from './primitives/NodeInfo/index.js';
const nodeInfo = NodeInfo.from(rpcResponse);
console.log(nodeInfo.name);     // "Geth/v1.10.26-stable"
console.log(nodeInfo.protocols.eth?.network); // NetworkId

getProtocol()

getProtocol(nodeInfo, protocolName): unknown
Defined in: src/primitives/NodeInfo/index.ts:13

Parameters

nodeInfo
any
protocolName
string

Returns

unknown