Skip to main content

Try it Live

Run Authorization examples in the interactive playground

Authorization

EIP-7702 authorization implementation enabling EOA code delegation.
New to EIP-7702 authorizations? Start with Fundamentals to learn delegation mechanics, security considerations, and complete examples.

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

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:
Important:
  • 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

  1. Create Unsigned Authorization
  2. Sign Authorization
  3. Include in Transaction
    • Authorization list included in EIP-7702 transaction
    • Each authorization processed at transaction start
  4. 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

Processing

Utilities

  • format - Format authorization to string
  • equals - Compare authorization equality
  • Helper functions for authorization manipulation

WASM

Constants

EIP-7702 Constants

Signature Constants

Use Cases

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:
Each function is independently exported, allowing bundlers to eliminate unused code. This is especially beneficial when only using a subset of Authorization functionality (e.g., only validation without signing).

Performance

Operation Complexity

Optimization Tips

  1. Batch validations - validate all before processing
  2. Cache gas calculations - if list doesn’t change
  3. Pre-compute hashes - reuse signing hashes when possible
  4. Limit list size - large lists increase gas costs significantly

See Also

References