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 GarnettMotivation
Problem: EOAs lack programmability of smart contract wallets:- No custom validation logic
- No batching
- No gas sponsorship
- No social recovery
- No multi-sig
Mechanism
Account Code Delegation
During EIP-7702 transaction execution:- Authorization Processing - Process authorization list at transaction start
- Code Delegation - Set EOA code pointer to delegated contract
- Transaction Execution - Execute transaction with delegated logic
- Delegation Revert - Clear code delegation after transaction
Authorization Structure
Authorization tuple:chain_id(uint256) - Chain ID where validaddress(address) - Contract to delegate tononce(uint256) - EOA noncey_parity(uint8) - Signature parity (0 or 1)r(uint256) - Signature r values(uint256) - Signature s value
Signing Hash
Authorization signing hash:MAGIC=0x05(EIP-7702 identifier)- RLP encoding uses compact representation
Transaction Format
New Transaction Type
EIP-7702 introduces transaction type0x04:
TransactionType=0x04TransactionPayload= RLP encoded transaction fields
Transaction Fields
authorization_list - List of authorizations to process
Authorization List
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
Processing Rules
Authorization Validation
Each authorization must:- Have non-zero chain ID
- Have non-zero address
- Have valid signature (r, s, v)
- Have s ≤ N/2 (non-malleable)
- Match current chain ID
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
- Hash unsigned authorization
- Recover public key from signature
- Derive address from public key
- This is the “authority” (EOA granting permission)
Code Delegation
For each authorization:- Recover authority (signer)
- Set authority’s code to point to delegated address
- Authority’s balance, nonce, storage unchanged
0xef0100- Delegation prefix (EOF format)address- 20-byte delegated address
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 signedSignature 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 hijackedStorage 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 storageUse 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
- Reuses existing infrastructure
- Simpler implementation
- More flexible (any contract logic)
- Better compatibility
Implementation Notes
RLP Encoding
Authorization RLP encoding:Signature Verification
Standard ECDSA signature verification:- Hash authorization
- Recover public key from signature
- Derive address from public key
Gas Metering
Gas charged at transaction start (before execution):Testing
Test Vectors
Valid authorization: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
- EIP-7702: Set EOA Account Code
- EIP-2718: Typed Transaction Envelope
- EIP-3074: AUTH and AUTHCALL opcodes
- EIP-191: Signed Data Standard
See Also
- Signing - Creating authorizations
- Validation - Validating authorizations
- Processing - Processing authorizations
- Gas Calculations - Gas costs

