---
eip: 7684
label: EIP-7684
title: Return deposits for distinct credentials
status: Stagnant
type: Standards Track
category: Core
created: 2024-04-12
official: https://eips.ethereum.org/EIPS/eip-7684
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7684.md
canonical: https://eips.huatuo.xyz/eip-7684/
lang: en
tldr: Proposes that a deposit to an existing validator with different withdrawal credentials be automatically returned (minus a penalty) instead of becoming a top-up, closing a deposit front-running attack.
tags: [staking, deposits, withdrawals, consensus, security]
---

# EIP-7684: Return deposits for distinct credentials

> Automatically withdraw deposits for existing validator records but with distinct execution withdrawal credentials

**TL;DR:** Proposes that a deposit to an existing validator with different withdrawal credentials be automatically returned (minus a penalty) instead of becoming a top-up, closing a deposit front-running attack.

## What problem does it solve?

Many staking setups split roles: one party runs the validator key, another party supplies the ETH. The funder needs to keep ultimate control of the money through the **withdrawal credentials** attached to the deposit.

The beacon chain only looks at the validator public key when it processes a deposit. If a validator already exists for that key, any further deposit is treated as a **top-up**, and the withdrawal credentials in the new deposit are ignored. That opens a front-running attack:

1. The funder broadcasts a full 32 ETH deposit for the operator's key, with the funder's withdrawal credentials.
2. The operator sees it and gets a small deposit for the same key included first, with *their own* withdrawal credentials.
3. The funder's big deposit lands as a top-up to a validator whose withdrawals go to the operator.

Today people work around this with distributed key generation, or by depositing 1 ETH first and topping up only after it is included. Both add friction, especially for trustless staking protocols. EIP-7684 limits the worst-case loss of a naive deposit to a fixed `RETURN_DEPOSIT_PENALTY`.

## How it works

This is a consensus-layer-only change; the execution layer is untouched. The detailed rules live in the consensus-specs repository; the EIP summarises them as:

- **`apply_deposit`**: if a deposit targets an existing validator but carries **distinct execution withdrawal credentials**, it is not credited. Instead it is queued as a *pending withdrawal* back to the address in those credentials.
- **`get_expected_withdrawals`**: pending withdrawals are returned first, ahead of the normal withdrawal sweep.
- **`process_withdrawals`**: clears the pending-withdrawal queue once paid.

A rejected deposit cannot be refunded in the same block it appears in. After [EIP-6110](/eip-6110/) deposits come from the execution payload, so the execution client would need to know the withdrawals before the deposits that trigger them exist. Rejected deposits are therefore paid out in a following slot; the spec processes all pending ones in the very next slot for simplicity.

## Sample code

Simplified pseudocode of the deposit rule:

```python
def apply_deposit(state, pubkey, withdrawal_credentials, amount, signature):
    index = find_validator_index(state, pubkey)
    if index is None:
        add_new_validator(state, pubkey, withdrawal_credentials, amount, signature)
        return

    existing = state.validators[index].withdrawal_credentials
    if is_execution_credential(withdrawal_credentials) and withdrawal_credentials != existing:
        # EIP-7684: do not top up someone else's validator; send the funds back
        refund = amount - RETURN_DEPOSIT_PENALTY
        state.pending_withdrawals.append(
            Withdrawal(address=withdrawal_credentials[12:], amount=refund)
        )
        return

    increase_balance(state, index, amount)  # normal top-up
```

## Things to know

- **Status: Stagnant.** It has not been scheduled for a hard fork; the front-running risk and the usual workarounds still apply on mainnet.
- It would require a consensus-layer hard fork.
- The spec notes a cost: the worst-case number of withdrawals per block rises sharply (from a fixed 16 to over a thousand at a 30M gas limit), adding unpriced work to blocks. The penalty is meant to discourage spamming rejected deposits.
- Later changes such as [EIP-7251](/eip-7251/) (consolidations, larger effective balances) and [EIP-7002](/eip-7002/) (execution-triggered withdrawals) changed how deposits and withdrawals interact, so this design would need revisiting before adoption.


---

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