EIPs Explained

EIP-7851 · Draft · Core · 2024-12-27

EIP-7851: Code-Controlled EOA Delegation

Extends EIP-7702 with a SETSELFDELEGATE opcode that lets wallet code change its own delegation and permanently disable the account's original private key.

What problem does it solve?

EIP-7702 lets an EOA point to smart-contract code via a delegation indicator 0xef0100 || delegate_address. The account can then use passkeys, multisig, social recovery or modules. But the original secp256k1 private key never loses its power: it can still sign transactions and re-delegate the account. If that key leaks, the smart-wallet protections are bypassed.

EIP-7851 lets the wallet code itself take over the delegation lifecycle and, in the process, permanently switch off the original key.

How it works

  • New indicator 0xef0101 || delegate_address = "ECDSA-disabled delegation". Code execution treats it exactly like 0xef0100.
  • SETSELFDELEGATE(delegate_address) opcode (byte TBD, 9500 gas). It acts only on the current execution-context address (the account running the code):
    1. if delegate_address is zero: push 0, no change;
    2. if the account's raw code is exactly 23 bytes starting with 0xef0100 or 0xef0101: set it to 0xef0101 || delegate_address, push 1;
    3. otherwise: push 0, no change. It halts exceptionally in a static context, and a revert rolls the change back.
  • Validation rules. Once an account has 0xef0101 code, any transaction signed by its ECDSA key is invalid and must be rejected by mempools, and any EIP-7702 authorization it signs is skipped.

So the first successful call permanently disables ECDSA authority; later calls can switch to a new delegate implementation, but the key never comes back. The gas cost is EIP-7702's per-authorization base cost minus the 3000 gas for signature recovery.

Sample code

Wallet code exposing the operation behind its own authorization (Solidity with a hypothetical opcode; no compiler supports it yet):

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract Wallet {
    function upgradeAndLockKey(address newImpl) external {
        require(msg.sender == address(this), "only self");     // e.g. via a 7821 batch
        _requireUserConfirmed();                                // passkey / multisig check
        bool ok;
        assembly {
            // ok := setselfdelegate(newImpl)   // SETSELFDELEGATE, opcode byte TBD
        }
        require(ok, "not a 7702 delegated account");
    }

    function _requireUserConfirmed() internal view { /* wallet-specific */ }
}

Account code before and after:

before: 0xef0100 || <old delegate>   ; key can still sign txs
after:  0xef0101 || <new delegate>   ; key can never sign protocol txs again

Things to know

  • Status: Draft. The opcode byte is not yet assigned.
  • The switch is irreversible. Wallets should only expose it after explicit user confirmation and treat it as the highest privilege.
  • It only blocks protocol-level use of the key. Contracts that verify ECDSA signatures themselves (for example token permit) will still accept signatures from that key. The companion proposal EIP-8151 addresses ecrecover.
  • Existing 0xef0100 delegations are unaffected.

#eip-7702 #account-abstraction #eoa #opcode #security

Details

Authors
Liyi Guo (@colinlyguo), Nicolas Consigny (@nconsigny)
Status
Draft
Type
Standards Track / Core
Created
2024-12-27
Requires

Machine-readable: Markdown · JSON