Skip to main content

Nethereum.AppChain.P2P.Server

NuGet: Nethereum.AppChain.P2P.Server | Source: src/Nethereum.AppChain.P2P.Server/

Nethereum.AppChain.P2P.Server

PREVIEW — This package is in preview. APIs may change between releases.

Nethereum AppChain node with integrated DotNetty P2P networking and Clique PoA consensus.

Overview

A complete AppChain node combining Clique Proof-of-Authority consensus, DotNetty P2P networking, and a full Ethereum JSON-RPC endpoint. It produces blocks, propagates them to peers, and serves RPC queries — all in one process.

The server supports multi-validator networks where authorised signers take turns producing blocks according to the Clique protocol, with blocks broadcast to all connected peers via the DotNetty transport layer.

Key Features

  • Complete Node: Combines consensus, block production, P2P, and RPC in one process
  • Clique PoA Consensus: Turn-based block production with dynamic validator voting
  • DotNetty P2P: High-performance peer-to-peer block propagation
  • JSON-RPC 2.0: Standard Ethereum RPC endpoint compatible with ethers.js/web3.js
  • Health & Status: Built-in /health and /status endpoints for monitoring
  • CLI Configuration: Command-line argument parsing for all node parameters

Installation

dotnet add package Nethereum.AppChain.P2P.Server

Dependencies

  • Nethereum.AppChain - Core chain abstraction and genesis
  • Nethereum.AppChain.Sequencer - Block production and transaction ordering
  • Nethereum.AppChain.P2P.DotNetty - DotNetty P2P transport
  • Nethereum.AppChain.Metrics - Prometheus metrics instrumentation
  • Nethereum.Consensus.Clique - Clique PoA consensus engine
  • Nethereum.CoreChain - RPC handler registry and storage
  • System.CommandLine - CLI argument parsing

Quick Start

dotnet run --project src/Nethereum.AppChain.P2P.Server -- \
--port 8546 \
--p2p-port 30303 \
--chain-id 420420 \
--name "MyChain" \
--signer-key 0xYOUR_PRIVATE_KEY \
--signers 0xSIGNER1,0xSIGNER2 \
--block-time 1000

Usage Examples

Example 1: Single Validator

dotnet run --project src/Nethereum.AppChain.P2P.Server -- \
--port 8546 \
--p2p-port 30303 \
--chain-id 420420 \
--name "TestChain" \
--signer-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
--block-time 1000

Example 2: Multi-Validator with Peer Connection

# Node 1 (Validator)
dotnet run -- --port 8546 --p2p-port 30303 \
--signer-key $KEY1 --signers $ADDR1,$ADDR2 \
--node-id "validator-1"

# Node 2 (Validator, connects to Node 1)
dotnet run -- --port 8547 --p2p-port 30304 \
--signer-key $KEY2 --signers $ADDR1,$ADDR2 \
--peers 127.0.0.1:30303 \
--node-id "validator-2"

HTTP Endpoints

MethodPathDescription
POST/JSON-RPC 2.0 endpoint (all eth_*, web3_*, net_* methods)
GET/healthHealth check ({"status": "healthy"})
GET/statusNode status (chain info, peers, block number)

CLI Options

OptionDefaultDescription
--host127.0.0.1HTTP listen address
--port8546HTTP listen port
--p2p-port30303P2P TCP listen port
--chain-id420420Chain ID
--nameAppChainChain name
--signer-key(required)Signer private key
--signersComma-separated initial signer addresses
--peersComma-separated bootstrap peer endpoints
--block-time1000Block production interval (ms)
--node-idHuman-readable node identifier

Dependencies

See Also

Additional Resources