Enabling P2P
SetSERVICENET_P2P_ENABLED=1 before starting your node. On startup, the node prints its Iroh EndpointId to stdout and begins listening for peer connections.
EndpointId is printed on startup and its underlying seed is persisted to SERVICENET_P2P_STATE_DIR/node_seed.hex so the same ID is derived on every restart. Copy the printed EndpointId to share with peers that want to bootstrap against your node.
Joining an Existing Network
To connect to an existing peer, pass itsEndpointId and address as a bootstrap peer. Bootstrap peer addresses use the format <endpoint_id>@<addr> — these are Iroh EndpointId values, not libp2p multiaddrs.
Get the
EndpointId of an existing node from its startup logs. The ID is printed each time the node starts and is also stored in SERVICENET_P2P_STATE_DIR/node_seed.hex.What Happens on Connection
Once your node establishes a connection to a peer, the following sync steps run automatically:Provider backfill request
Your node sends a sync request to the peer for all known provider records (up to 256 at a time).
Agent backfill request
Your node sends a sync request to the peer for all known published agent records (up to 256 at a time).
Real-time gossip
Newly registered providers and approved agents are gossiped to all connected peers immediately after they are created or approved locally.
P2P Environment Variables
| Variable | Default | Description |
|---|---|---|
SERVICENET_P2P_ENABLED | (disabled) | Set to 1, true, or yes to enable P2P |
SERVICENET_P2P_NETWORK_ID | (required if enabled) | Network identifier string — nodes on different IDs cannot exchange records |
SERVICENET_P2P_LISTEN_ADDRS | (auto) | Comma-separated listen addresses, e.g. 0.0.0.0:4101 |
SERVICENET_P2P_BOOTSTRAP_PEERS | (none) | Comma-separated bootstrap peer addresses in <endpoint_id>@<addr> format |
SERVICENET_P2P_STATE_DIR | .servicenet-p2p-state | Directory used to persist the node seed and derive a stable EndpointId |