Try it Live
Run Authorization examples in the interactive playground
Conceptual Guide - For API reference and method documentation, see Authorization API.
What is EIP-7702 Authorization?
An authorization is a signed message allowing an EOA to temporarily set its code pointer to a smart contract’s code for a single transaction. After the transaction, the EOA reverts to its normal state. Key Characteristics:- Temporary - Delegation lasts only one transaction
- Signed - EOA owner must explicitly sign authorization
- Per-transaction - Included in transaction’s authorization list
- Non-invasive - EOA retains original balance, nonce, storage
Why EIP-7702 Exists
The Account Abstraction Problem
Traditional EOAs have limitations:- Can’t batch operations (need multiple transactions)
- Can’t sponsor gas (user always pays)
- Can’t implement custom validation logic
- Can’t recover if keys are lost
- Migrating funds to new contract address
- Losing original EOA identity
- CREATE2 deployment complexity
Use Cases
- Sponsored Transactions - Relayer pays gas, user signs authorization
- Batch Operations - Multiple token approvals, swaps, transfers in one transaction
- Social Recovery - Guardian-based recovery without moving funds
- Session Keys - Temporary signing keys for games, dApps
- Custom Validation - Multi-sig, time locks, spending limits
Authorization Structure
An authorization contains 6 fields:Field Details
chainId - Prevents cross-chain replay attacks. Authorization signed for mainnet (1) is invalid on Optimism (10). address - The smart contract that will execute in your EOA’s context. Choose trusted contracts only. nonce - Your EOA’s current nonce. Prevents replaying old authorizations. yParity, r, s - secp256k1 signature components proving you authorized this delegation.Delegation Mechanics
Before Authorization
During Transaction with Authorization
- Calls to EOA address execute delegated contract’s code
msg.senderin delegated contract is the transaction senderaddress(this)is the EOA address- Contract reads/writes its own storage (NOT EOA’s storage)
After Transaction
Authorization Lifecycle
1. Create Unsigned Authorization
Define what to delegate and where:2. Sign Authorization
EOA owner signs with their private key:- RLP-encodes
[chainId, address, nonce] - Prepends EIP-7702 magic byte (0x05)
- Keccak256 hashes the result
- Signs hash with secp256k1
- Returns authorization with signature fields
3. Include in Transaction
Authorization list is added to EIP-7702 transaction:4. Processing at Execution
When transaction executes:- Validate - Check signature, nonce, chain ID
- Recover Authority - Extract EOA address from signature
- Set Code Delegation - Point authority’s code to delegated address
- Deduct Gas - Charge authorization processing costs
- Execute Transaction - Run transaction with delegated code active
- Revert Delegation - Remove code pointer after transaction
Complete Example: Sponsored Transaction
User wants to swap tokens but has no ETH for gas. Relayer sponsors the transaction.Step 1: User Creates Authorization
Step 2: Relayer Builds Transaction
Step 3: Execution Flow
Step 4: Verify Authority
Relayer can verify who authorized the delegation:Security Considerations
What Can Be Delegated
Safe to delegate:- Code execution logic
- Transaction batching
- Gas payment
- Custom validation rules
- Private keys (always remain with EOA owner)
- Existing ETH balance (stays in EOA)
- Existing storage (remains unchanged)
- Permanent account state
Authority vs Sender
Understand the difference:Signature Validation
Always validate before processing:Nonce Management
Nonces prevent replay attacks:Chain ID Validation
Prevent cross-chain replay:Delegated Contract Trust
Only delegate to trusted contracts:Gas Implications
Authorization Processing Costs
Each authorization costs gas to process:Multiple Authorizations
Transaction can include multiple authorizations:Gas Optimization Tips
- Reuse existing contracts - Avoid empty account cost (25k gas)
- Minimize authorization count - Each costs 12.5k gas minimum
- Batch operations - Use one authorization for multiple actions
- Cache validation - Don’t validate same authorization multiple times
Visual Flow Diagrams
Authorization Creation Flow
Transaction Execution Flow
Sponsored Transaction Flow
Signing Hash Calculation
Understanding how the signing hash is computed:-
RLP Encode -
[chainId, address, nonce] -
Prepend Magic Byte -
0x05 || rlpEncoded -
Keccak256 Hash
- Result - 32-byte signing hash
(yParity, r, s).
Authority Recovery
Extract the EOA address that signed an authorization:- Recalculate signing hash from
(chainId, address, nonce) - Use
ecrecoverwith(hash, yParity, r, s)to extract public key - Hash public key with keccak256 and take last 20 bytes
- Result is the EOA address (authority)
Batch Processing
Process multiple authorizations efficiently:Comparison: Traditional vs EIP-7702
Scenario: User Wants to Swap 3 Tokens
Traditional EOA:- Fewer transactions (1 vs 4)
- Better UX (no gas for user)
- Atomic execution (all or nothing)
- Lower total gas cost
Resources
Specifications
- EIP-7702: Set EOA Account Code - Full specification
- EIP-2718: Typed Transaction Envelope - Transaction type framework
- EIP-191: Signed Data Standard - Signature format
Related Topics
- Account Abstraction - ERC-4337 alternative approach
- Transaction Types - Tevm transaction documentation
- Signature Verification - secp256k1 cryptography
- RLP Encoding - Recursive Length Prefix encoding
Next Steps
- Overview - Type definition and complete API reference
- Validation - Authorization structure validation
- Signing - Create and verify signatures
- Gas Calculations - Calculate processing costs
- Processing - Process authorization lists

