Try it Live
Run Authorization examples in the interactive playground
Authorization
EIP-7702 authorization implementation enabling EOA code delegation.Overview
Authorizations (EIP-7702) allow Externally Owned Accounts (EOAs) to temporarily delegate code execution to smart contracts, enabling account abstraction features without migrating to contract wallets. Key Features:- Account abstraction for EOAs
- Sponsored transactions (gas abstraction)
- Batch operations
- Social recovery
- Custom validation logic
- Temporary, per-transaction delegation
Quick Start
- Functional API
Core Types
Authorization.Item
Complete signed authorization.Authorization.Unsigned
Authorization before signing.Authorization.DelegationDesignation
Result of processing authorization.Set Code Delegation
EIP-7702 allows EOA to set its code to point to contract’s code:- Delegation is per-transaction - resets after transaction
- Original EOA retains ownership and keys
- Delegated contract executes in EOA’s context
- EOA’s storage remains separate
Workflow
-
Create Unsigned Authorization
-
Sign Authorization
-
Include in Transaction
- Authorization list included in EIP-7702 transaction
- Each authorization processed at transaction start
-
Execution
- EOA code set to delegated contract
- Transaction executes with delegated logic
- Code delegation reverts after transaction
Visual Guides & Examples
Workflows & Diagrams
Comprehensive visual explanations:- EIP-7702 Account Delegation Flow - EOA → delegate → execute → revert
- Authorization Lifecycle - Creation, signing, processing, execution
- Sponsored Transaction Flow - User signs auth, relayer pays gas
- Batch Operations - Multiple actions in single transaction
- Social Recovery - Guardian-based account recovery
- Gas Cost Breakdown - Per-authorization and transaction costs
- Comparison Tables - Traditional vs EIP-7702 approaches
Real-World Examples
Production-ready implementations:- Relay Network Integration - Gas-sponsoring relay service
- Batch Operation Contract - Multi-action execution
- Social Recovery Implementation - Guardian-based recovery
- Smart Account Using Delegation - EOA-as-smart-account pattern
- Gasless Transaction Service - End-to-end gasless UX
- Production Deployment Checklist - Validation & testing
API Methods
Type Guards
- Check if value is Authorization.Item or Authorization.Unsigned
Validation
- validate - Validate authorization structure and signature components
Signing & Hashing
- hash - Calculate signing hash
- sign - Create signed authorization
- verify - Recover authority from signature
Gas Calculations
- getGasCost - Calculate gas cost for single authorization
- calculateGasCost - Calculate gas costs for authorization lists
Processing
- process - Process single authorization
- processAll - Process authorization lists
Utilities
- format - Format authorization to string
- equals - Compare authorization equality
- Helper functions for authorization manipulation
WASM
- WASM-accelerated operations - Validation, hashing, and gas calculation
Constants
EIP-7702 Constants
Signature Constants
Use Cases
Sponsored Transactions
Allow relayer to pay gas for user transactions:Batch Operations
Execute multiple operations in single transaction:Social Recovery
Implement social recovery for EOAs:Best Practices
1. Always Validate
2. Check Nonce Consistency
3. Estimate Gas Accurately
4. Handle Failures Gracefully
5. Use Type Guards
6. Prevent Signature Malleability
7. Chain-Specific Authorizations
Security Considerations
1. Signature Verification
Always verify signatures before executing delegated code:2. Nonce Tracking
Prevent replay attacks by tracking nonces:3. Chain ID Validation
Prevent cross-chain replay:4. Address Validation
Ensure delegated address is trusted:5. Gas Limits
Set appropriate gas limits to prevent DoS:Tree-Shaking
Import only what you need for optimal bundle size:Performance
Operation Complexity
| Operation | Time | Notes |
|---|---|---|
isItem | O(1) | Type checking |
isUnsigned | O(1) | Type checking |
validate | O(1) | Constant checks |
hash | O(1) | RLP + keccak256 |
sign | O(1) | secp256k1 signing |
verify | O(1) | Signature recovery |
calculateGasCost | O(n) | n = list length |
processAll | O(n) | n = list length |
format | O(1) | String formatting |
equals | O(1) | Field comparison |
Optimization Tips
- Batch validations - validate all before processing
- Cache gas calculations - if list doesn’t change
- Pre-compute hashes - reuse signing hashes when possible
- Limit list size - large lists increase gas costs significantly
See Also
- EIP-7702 Specification
- Validation
- Signing & Verification
- Gas Calculations
- Processing
- Utilities
- WASM
- Usage Patterns

