EIP-7702 enables externally owned accounts (EOAs) to delegate their execution to smart contract code, allowing EOA wallets to function like smart contract wallets.
Overview
EIP-7702 is a groundbreaking proposal that allows EOA wallets to temporarily delegate their code execution to a smart contract. This enables powerful account abstraction features without requiring users to migrate to new wallet addresses.Key Benefits
- Transaction batching: Execute multiple operations in a single transaction
- Gas sponsorship: Enable gasless transactions for users
- Custom permissions: Implement spending limits and approval logic
- Session keys: Allow temporary key access with limited permissions
- Social recovery: Add recovery mechanisms to EOA wallets
- Backwards compatibility: EOAs can revert to normal operation anytime
How It Works
- User signs an EIP-7702 authorization delegating to a contract
- Authorization is included in a transaction
- During that transaction, the EOA behaves like the delegated contract
- After the transaction, the EOA returns to normal
- Authorization can be revoked or updated at any time
React SDK
- Basic Usage
- With UI Customization
To sign an EIP-7702 authorization, use the
sign7702Authorization method from the useSign7702Authorization hook:Parameters
string
required
The address of the smart contract whose code the EOA will delegate to. This is typically an account implementation contract from your AA provider.Example:
number
required
The chain ID where the authorization will be used.Example:
number
The nonce for the authorization. If not provided, the current transaction count for the wallet will be used automatically.Example:
Options Object
The second parameter is an optional configuration object:object
Configuration for the authorization confirmation modal.
Wallet
Specific wallet to use for signing. If not provided, uses the user’s default wallet.
Returns
object
The signed EIP-7702 authorization object.
Complete Examples
Enable Gas Sponsorship
UI Customization
Customize the authorization signing modal:Hide Modal
Best Practices
Validate contract implementation
Validate contract implementation
Always verify the contract address before delegating:
Use appropriate chain IDs
Use appropriate chain IDs
Ensure the chain ID matches your target network:
Manage nonces carefully
Manage nonces carefully
Let MoonKey handle nonces automatically unless you have specific requirements:
Educate users about delegation
Educate users about delegation
Clearly explain what authorization means:
Provide revocation mechanism
Provide revocation mechanism
Allow users to revoke authorization:
Handle errors gracefully
Handle errors gracefully
Provide clear error messages:
Troubleshooting
Network mismatch
Network mismatch
Ensure user is on the correct network:
Invalid contract address
Invalid contract address
Validate contract addresses:
Related Documentation
EIP-7702 Specification
Official EIP-7702 documentation
Sign Transaction
Sign transactions without broadcasting
Send Transaction
Send transactions to the network
Sign Message
Sign messages for authentication
Next Steps
- Learn about EIP-7702 specification details
- Explore account abstraction providers and their implementations
- Understand how to batch transactions with AA
- Implement gas sponsorship for your users
- Set up session keys for automated transactions