This project demonstrates EIP-7702 authorization using the MetaMask Delegation Toolkit, allowing users to upgrade their Externally Owned Accounts (EOAs) to support MetaMask Smart Accounts functionality.
- EIP-7702 Authorization: Authorize your EOA to use delegatee contracts
- MetaMask deleGator Core Support: Integration with MetaMask's core delegation contracts
- Smart Account Creation: Create MetaMask Smart Account instances
- User Operations: Send user operations through upgraded EOAs
- Real-time Logging: Comprehensive operation logs for debugging
- Modern UI: Beautiful, responsive interface with Tailwind CSS
EIP-7702 enables your externally owned account (EOA) to support MetaMask Smart Accounts functionality using an EIP-7702 transaction. This allows your EOA to leverage the benefits of account abstraction, such as:
- Batch transactions
- Gas sponsorship
- ERC-7710 delegation capabilities
- Enhanced security features
The authorization process follows these steps:
- Select Delegatee Contract: Choose from available delegatee contracts (e.g., MetaMask deleGator Core)
- Sign Authorization: Create and sign an EIP-7702 authorization
- Submit Transaction: Submit the authorization to the blockchain
- Create Smart Account: Instantiate a MetaMask Smart Account
- Send User Operations: Execute transactions through the upgraded account
The implementation uses the MetaMask Delegation Toolkit and follows the official documentation:
// Authorize 7702 delegation
const authorization = await walletClient.signAuthorization({
account: address,
contractAddress: selectedContract.address,
executor: 'self',
});
// Submit authorization
const hash = await walletClient.sendTransaction({
authorizationList: [authorization],
data: '0x',
to: zeroAddress,
});
// Create smart account
const smartAccount = await toMetaMaskSmartAccount({
client: publicClient,
implementation: Implementation.Stateless7702,
address,
signatory: { walletClient },
});- Node.js 18+
- MetaMask wallet
- Sepolia testnet ETH
-
Clone the repository
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open http://localhost:3000 in your browser
- Connect Wallet: Click "Connect Wallet" and connect your MetaMask wallet
- Select Contract: Choose a delegatee contract from the available options
- Authorize: Click "Authorize 7702" to sign the authorization
- Submit: Click "Submit Authorization" to broadcast the transaction
- Create Smart Account: Create a MetaMask Smart Account instance
- Send User Operation: Execute transactions through your upgraded account
- Sepolia Testnet: Primary testing network
- Mainnet: Production deployment (when available)
- Address: Dynamically resolved from MetaMask Delegation Toolkit
- Implementation:
EIP7702StatelessDeleGatorImpl - Description: Core MetaMask deleGator implementation for EIP-7702
- Address: Configurable
- Implementation:
Implementation.Stateless7702 - Description: Custom implementation for EIP-7702 delegation
- Navigation: Page navigation between ZeroDev and MetaMask demos
- EIP7702Page: Main authorization dashboard
- ConnectButton: Wallet connection interface
- Operation Logs: Real-time operation tracking
- @metamask/delegation-toolkit: MetaMask Delegation Toolkit
- viem: Ethereum client library
- wagmi: React hooks for Ethereum
- @rainbow-me/rainbowkit: Wallet connection UI
- Next.js: React framework
The application uses React hooks for state management:
useState: Local component stateuseEffect: Side effects and initializationuseAccount: Wallet connection stateusePublicClient: Blockchain clientuseWalletClient: Wallet operations
The application includes comprehensive error handling:
- Network Errors: Graceful handling of RPC failures
- User Rejections: Proper handling of user transaction rejections
- Validation: Input validation and parameter checking
- Logging: Detailed operation logs for debugging
- Private Key Security: Never expose private keys in the frontend
- Transaction Validation: Validate all transaction parameters
- Network Verification: Ensure correct network selection
- Authorization Limits: Implement appropriate authorization restrictions
src/
├── app/
│ ├── components/
│ │ └── Navigation.tsx
│ ├── eip7702/
│ │ └── page.tsx
│ ├── layout.tsx
│ ├── page.tsx
│ └── providers.tsx
├── globals.css
└── ...
npm run dev: Start development servernpm run build: Build for productionnpm run start: Start production servernpm run lint: Run ESLint
Create a .env.local file with:
NEXT_PUBLIC_ZERODEV_PROJECT_ID=your_project_id- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
- MetaMask Delegation Toolkit Documentation
- EIP-7702 Specification
- Viem Documentation
- Wagmi Documentation
For support and questions:
- Check the operation logs for detailed error information
- Review the MetaMask Delegation Toolkit documentation
- Ensure you're connected to the correct network
- Verify your wallet has sufficient funds for gas fees