---
eip: 868
label: EIP-868
title: Node Discovery v4 ENR Extension
status: Final
type: Standards Track
category: Networking
created: 2018-02-02
requires: 8, 778
official: https://eips.ethereum.org/EIPS/eip-868
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-868.md
canonical: https://eips.huatuo.xyz/eip-868/
lang: en
tldr: "Extends Ethereum's discv4 peer discovery with packets to request a node's signed Ethereum Node Record (ENR), so peers can always fetch the latest, authoritative info about a node."
tags: [networking, devp2p, discovery, enr]
---

# EIP-868: Node Discovery v4 ENR Extension

> This EIP defines an extension to Node Discovery Protocol v4 to enable authoritative resolution of Ethereum Node Records (ENR).

**TL;DR:** Extends Ethereum's discv4 peer discovery with packets to request a node's signed Ethereum Node Record (ENR), so peers can always fetch the latest, authoritative info about a node.

## What problem does it solve?

Ethereum nodes find each other with the Node Discovery Protocol v4 (discv4), a Kademlia-style UDP protocol. Originally a discv4 entry held only an IP, ports and public key. [EIP-778](/eip-778/) introduced **Ethereum Node Records (ENR)**: signed, versioned, extensible records that can also advertise things like which chain or fork a node is on.

But discv4 had no way to ask a node "send me your current record". Without that, ENRs could not be resolved reliably over the existing discovery network, or bridged to other channels such as DNS. EIP-868 adds the missing request and response.

## How it works

Two existing packets gain a field, and two new packets are added:

| Packet | Type | Data |
| --- | --- | --- |
| Ping | `0x01` | `[version, from, to, expiration, enr-seq]` |
| Pong | `0x02` | `[to, ping-hash, expiration, enr-seq]` |
| ENRRequest | `0x05` | `[expiration]` |
| ENRResponse | `0x06` | `[request-hash, ENR]` |

- **`enr-seq`** in Ping and Pong is the sender's current ENR sequence number. If you see a higher number than the one you have cached, the node's record has changed and is worth re-fetching.
- **ENRRequest** asks for the record. To prevent UDP amplification attacks, a node should only answer if the requester has recently completed a ping/pong exchange, as for `FindNode`. Expired requests are ignored.
- **ENRResponse** returns the record and the hash of the request it answers. The receiver must check that the ENR is signed by the node that sent it.

**Resolving a record by public key:** run the normal recursive Kademlia lookup (`FindNode` / `Neighbors`) to locate the node, then send it an ENRRequest.

## Sample code

Pseudocode for keeping a peer's record fresh:

```python
def on_pong(peer, pong):
    # pong.enr_seq was added by EIP-868
    if pong.enr_seq > cache.get_seq(peer.id):
        send(peer, ENRRequest(expiration=now() + 20))

def on_enr_response(peer, resp):
    assert resp.request_hash == last_request_hash(peer)
    record = rlp_decode(resp.enr)
    assert record.verify_signature(peer.public_key)   # must be signed by sender
    assert record.seq >= cache.get_seq(peer.id)
    cache.store(peer.id, record)
```

ENRs are often shared as text, base64 with an `enr:` prefix:

```text
enr:-IS4QHCYrYZbAKWCBRlAy5zzaDZXJBGkcnh4MHcBFZntXNFrdvJjX04jRzjzCBOonrkTfj499SZuOh8R33Ls8RRcy5wBgmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQPKY0yuDUmstAHYpMa2_oxVtw0RW_QAdpzBQA8yWM0xOIN1ZHCCdl8
```

(This is the example record from EIP-778.)

## Things to know

- This EIP is **Final** and implemented in execution clients that run discv4.
- ENRs can carry an `eth` entry with the fork identifier from [EIP-2124](/eip-2124/), which helps nodes skip peers on the wrong chain early.
- Records fetched this way can also be published through DNS lists ([EIP-1459](/eip-1459/)).
- Its successor protocol, discv5, uses ENRs natively and is what consensus-layer clients use for discovery.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-868
