---
eip: 4881
label: EIP-4881
title: Deposit Contract Snapshot Interface
status: Final
type: Standards Track
category: Interface
created: 2021-01-29
official: https://eips.ethereum.org/EIPS/eip-4881
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4881.md
canonical: https://eips.huatuo.xyz/eip-4881/
lang: en
tldr: Defines a compact snapshot of the beacon chain deposit Merkle tree, served at a standard Beacon API endpoint, so new consensus clients can rebuild it without replaying every historical deposit.
tags: [consensus, deposits, beacon-api, sync, staking]
---

# EIP-4881: Deposit Contract Snapshot Interface

> Establishing the format and endpoint for transmitting a snapshot of the deposit Merkle tree

**TL;DR:** Defines a compact snapshot of the beacon chain deposit Merkle tree, served at a standard Beacon API endpoint, so new consensus clients can rebuild it without replaying every historical deposit.

## What problem does it solve?

Every validator joins by sending ETH to the deposit contract on the execution layer. The contract keeps an incremental Merkle tree of all deposits, and beacon blocks must include each new deposit with a Merkle proof against that tree.

To build those proofs, most consensus clients downloaded and stored *every* deposit log since the contract launched. That slowed down new nodes, especially those using weak-subjectivity (checkpoint) sync, and it prevented execution nodes from ever pruning old logs. Yet once a deposit has been processed and finalized, most of the hashes on its path are never needed again.

EIP-4881 standardises a small snapshot of just the parts of the tree that still matter, and an endpoint to fetch it.

## How it works

Clients may store the tree however they like internally, but when transmitting it they must use:

```python
class DepositTreeSnapshot:
    finalized: List[Hash32, DEPOSIT_CONTRACT_DEPTH]  # roots of fully finalized subtrees
    deposit_root: Hash32
    deposit_count: uint64
    execution_block_hash: Hash32
    execution_block_height: uint64
```

- `finalized` holds, for the finalized part of the tree, only the root hash of each complete left subtree. With a depth-32 tree this is at most 32 hashes, whatever the number of deposits.
- `deposit_root`, `deposit_count` and `execution_block_hash` match the beacon chain's `Eth1Data` for that point. `execution_block_height` is included too, so a syncing client does not have to ask a possibly unsynced execution engine for it.
- A receiver can recompute the root from `finalized` and `deposit_count` and compare it with `deposit_root` to validate the snapshot cheaply.
- New deposits after the snapshot are appended on top, and proofs can be generated from there.

Consensus clients serve the snapshot at the Beacon Node API endpoint `/eth/v1/beacon/deposit_snapshot`. Once deposits pass the finalization conditions, clients may prune the hashes underneath.

## Sample code

Fetching the snapshot from a beacon node (TypeScript):

```ts
const res = await fetch(`${process.env.BEACON_URL}/eth/v1/beacon/deposit_snapshot`);
const { data } = await res.json();

console.log(data.deposit_count);            // number of deposits covered
console.log(data.finalized.length);         // at most 32 hashes
console.log(data.execution_block_hash);
```

Validating a snapshot, adapted from the spec's reference implementation:

```python
def calculate_root(snap) -> Hash32:
    size, index = snap.deposit_count, len(snap.finalized)
    root = zerohashes[0]
    for level in range(DEPOSIT_CONTRACT_DEPTH):
        if size & 1:
            index -= 1
            root = sha256(snap.finalized[index] + root)
        else:
            root = sha256(root + zerohashes[level])
        size >>= 1
    return sha256(root + to_le_bytes(snap.deposit_count))  # mix in the count

assert calculate_root(snap) == snap.deposit_root
```

## Things to know

- This is an **Interface** EIP for consensus clients and node operators; it does not change consensus rules or the deposit contract, and is fully backwards compatible.
- Snapshots are trusted data from whoever serves them, much like a checkpoint-sync state. Fetch them from a node you trust and check the root.
- The spec includes test vectors and a reference implementation in Python.
- [EIP-6110](/eip-6110/) later moved deposit delivery onto the execution layer, which reduces how much clients rely on the old `Eth1Data` deposit flow over time.


---

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