NetworkId
Type-safe Ethereum network identifiers for peer-to-peer network discovery.Overview
Brandednumber type representing Ethereum network IDs. Network IDs are used for peer-to-peer network identification and discovery, distinct from Chain IDs which are used for transaction replay protection.
Quick Start
Network Constants
| Constant | Value | Network |
|---|---|---|
MAINNET | 1 | Ethereum Mainnet |
SEPOLIA | 11155111 | Sepolia Testnet |
HOLESKY | 17000 | Holesky Testnet |
GOERLI | 5 | Goerli Testnet (deprecated) |
API Reference
Constructors
Methods
NetworkId vs ChainId
Understanding the difference:| Aspect | NetworkId | ChainId |
|---|---|---|
| Purpose | P2P network discovery | Transaction replay protection |
| Protocol | devp2p | EIP-155 |
| RPC Method | net_version | eth_chainId |
| Used In | Peer handshake | Transaction signing |
Use Cases
Network Detection
Multi-Network Support
Node Connection Validation
Related
- Chain - Chain configuration with ChainId
- PeerId - Peer identifiers for P2P
- NodeInfo - Node information structure
References
- EIP-155 - Chain ID for replay protection
- devp2p Protocol - Ethereum P2P networking
- JSON-RPC net_version - RPC method

