Skip to main content

Try it Live

Run Authorization examples in the interactive playground

EIP-7702 Specification

Detailed explanation of EIP-7702: Set EOA Account Code.

Overview

EIP-7702 introduces a new transaction type that allows Externally Owned Accounts (EOAs) to temporarily delegate their code execution to a smart contract. This enables account abstraction features for regular EOAs without requiring migration to contract wallets. Specification: EIP-7702: Set EOA Account Code Status: Draft (as of documentation) Authors: Vitalik Buterin, Sam Wilson, Ansgar Dietrichs, Matt Garnett

Motivation

Problem: EOAs lack programmability of smart contract wallets:
  • No custom validation logic
  • No batching
  • No gas sponsorship
  • No social recovery
  • No multi-sig
Solution: Allow EOAs to temporarily delegate code execution to contracts, enabling account abstraction features while maintaining EOA ownership.

Mechanism

Account Code Delegation

During EIP-7702 transaction execution:
  1. Authorization Processing - Process authorization list at transaction start
  2. Code Delegation - Set EOA code pointer to delegated contract
  3. Transaction Execution - Execute transaction with delegated logic
  4. Delegation Revert - Clear code delegation after transaction
Key Point: Delegation is per-transaction only. EOA reverts to normal after transaction completes.

Authorization Structure

Authorization tuple:
Fields:
  • chain_id (uint256) - Chain ID where valid
  • address (address) - Contract to delegate to
  • nonce (uint256) - EOA nonce
  • y_parity (uint8) - Signature parity (0 or 1)
  • r (uint256) - Signature r value
  • s (uint256) - Signature s value

Signing Hash

Authorization signing hash:
Where:
  • MAGIC = 0x05 (EIP-7702 identifier)
  • RLP encoding uses compact representation
TypeScript Implementation:
Zig Implementation:

Transaction Format

New Transaction Type

EIP-7702 introduces transaction type 0x04:
Where:
  • TransactionType = 0x04
  • TransactionPayload = RLP encoded transaction fields

Transaction Fields

New Field: authorization_list - List of authorizations to process

Authorization List

Each authorization:

Gas Costs

Per Authorization

Base cost: 12,500 gas Empty account cost: 25,000 gas additional Total per authorization:
  • Non-empty account: 12,500 gas
  • Empty account: 37,500 gas (12,500 + 25,000)

Total Transaction Cost

Example:
TypeScript Calculation:

Processing Rules

Authorization Validation

Each authorization must:
  1. Have non-zero chain ID
  2. Have non-zero address
  3. Have valid signature (r, s, v)
  4. Have s ≤ N/2 (non-malleable)
  5. Match current chain ID
Invalid authorizations: Transaction fails

Nonce Handling

Current nonce: Authorization uses EOA’s current nonce Nonce increment: EOA nonce increments during processing (per EIP-7702) Multiple authorizations from same EOA:

Authority Recovery

  1. Hash unsigned authorization
  2. Recover public key from signature
  3. Derive address from public key
  4. This is the “authority” (EOA granting permission)
TypeScript:
Zig:

Code Delegation

For each authorization:
  1. Recover authority (signer)
  2. Set authority’s code to point to delegated address
  3. Authority’s balance, nonce, storage unchanged
Code pointer format:
Where:
  • 0xef0100 - Delegation prefix (EOF format)
  • address - 20-byte delegated address
After transaction: Code pointer cleared

Security Considerations

Replay Protection

Chain ID: Authorization includes chain ID, preventing cross-chain replay Nonce: Authorization includes nonce, preventing same-chain replay Signature: Each authorization uniquely signed

Signature Malleability

Problem: ECDSA signatures have malleability - given (r, s), signature (r, -s mod N) also valid Solution: Require s ≤ N/2 Validation:

Temporary Delegation

Scope: Delegation only during transaction execution Persistence: Cleared after transaction Safety: EOA retains control - can’t be permanently hijacked

Storage Separation

EOA storage: Remains separate from delegated contract Delegated contract: Cannot directly modify EOA’s storage Context: Delegated code executes in EOA’s context but with separate storage

Use Cases

1. Sponsored Transactions

User signs authorization, relayer pays gas:

2. Batch Operations

Execute multiple operations atomically:

3. Social Recovery

Guardians can recover account:

4. Upgraded Logic

EOA delegates to upgraded contract:

Differences from EIP-3074

EIP-7702 improves upon EIP-3074: EIP-3074:
  • New opcodes: AUTH, AUTHCALL
  • More complex implementation
  • Less flexible
EIP-7702:
  • Reuses existing infrastructure
  • Simpler implementation
  • More flexible (any contract logic)
  • Better compatibility

Implementation Notes

RLP Encoding

Authorization RLP encoding:
Compact encoding: Remove leading zeros from bigints Example:

Signature Verification

Standard ECDSA signature verification:
  1. Hash authorization
  2. Recover public key from signature
  3. Derive address from public key
Note: Use secp256k1 curve (same as Ethereum)

Gas Metering

Gas charged at transaction start (before execution):
Revert behavior: If execution reverts, authorization gas NOT refunded

Testing

Test Vectors

Valid authorization:
Signing hash:

Edge Cases

Zero nonce: Valid (account starting nonce) Large nonce: Valid (any uint64) Zero address: Invalid (cannot delegate to zero) Zero chain ID: Invalid High s value: Invalid (malleable signature)

References

See Also