A modern demo implementing EIP-7702 for EOA account abstraction using wagmi/experimental useSendCalls
:
- π Zero Setup: No smart account deployment needed
- π¦ MetaMask Integration: Auto-prompts to upgrade EOA to smart account
- β‘ Atomic Execution: All transactions succeed or all fail
- π¦ ERC-5792 Compliant: Using
wallet_sendCalls
standard - π― Preset Templates: 8 ready-to-use templates for common use cases
- β½ Gas Estimation: Compare batch vs sequential gas costs
- οΏ½ Transaction History: Auto-save and track all batch transactions
- π Enhanced Result Viewer: Decode 50+ common function signatures
- π Revoke Delegation: Reset account to normal EOA anytime
π Perfect for: Simple batch transactions, quick demos, minimal complexity
- /docs - Complete EIP-7702 specification, motivation, and technical details
- /reference - Code examples, tutorials, and best practices
- Demo - Live interactive demo with batch transactions
- EIP-7702 Implementation Guide
- Comparison V1 vs V2
- Revoke Delegation Guide - Complete guide with 4 methods
- Revoke Implementation - Quick start & API reference
- Revoke Examples - Copy-paste code snippets
- π Authorization Signing: Sign authorization to delegate EOA to smart contract
- β‘ Batch Transactions: Modern approach with
useSendCalls
- MetaMask automatically handles authorization - π Session Keys: Manage session keys with expiration
- π Monitoring: Track delegation status and activities
- π Revoke Delegation: Reset account to normal EOA - clear delegation anytime
- UI component with status display in Info tab
- Multiple revoke methods (Hook, Viem)
- Complete documentation with examples
- β½ Gas Estimation: See gas costs before submitting - compare batch vs sequential
- π― Preset Templates: 8 ready-to-use templates for common use cases (DeFi, NFT, Transfers)
- Multi-Token Transfer
- DeFi Approve + Swap
- NFT Batch Mint
- Social Recovery Setup
- Payment Batch
- Test Templates (Simple & Self-transfers)
- π Transaction History: Auto-save all batch transactions with full details
- Persistent localStorage storage (last 100 transactions)
- Search and filter by status, date, or batch ID
- Export/Import history as JSON
- Statistics dashboard (total, confirmed, pending, failed)
- Quick access to transaction details and receipts
- π Enhanced Result Viewer: Detailed transaction decoder and analyzer
- Function Decoder: Automatically decode 50+ common function signatures
- ERC20: transfer, approve, transferFrom
- ERC721/1155: safeTransferFrom, setApprovalForAll
- Uniswap V2/V3: swap functions
- WETH: deposit, withdraw
- Transaction Details: Beautiful UI showing:
- Decoded function names and arguments
- Transaction type detection (Transfer, Swap, Approval, etc.)
- Gas usage with color-coded warnings
- Value transfers in ETH and wei
- Raw data with copy-to-clipboard
- Visual Timeline: Step-by-step execution flow
- Transaction submitted timestamp
- Confirmation with block number
- Failed status with error messages
- Share & Export: Share transaction details easily
- Expandable Call Details: Click to view full details for each call
- Etherscan Integration: Direct links to addresses and transactions
- Function Decoder: Automatically decode 50+ common function signatures
- π Interactive Docs Page: Complete EIP-7702 specification with examples
- π» Code Reference: Copy-paste ready code snippets for all use cases
- π¨ Visual Flow Diagrams: Step-by-step visualization of EIP-7702 and EIP-7710 processes
- π§ Navigation Bar: Easy access to Demo, Docs, and Reference sections
- β Best Practices Guide: Production-ready recommendations and troubleshooting
eip-7702/
βββ src/
β βββ app/ # Next.js 15 App Router
β β βββ page.tsx # Home/Demo page
β β βββ docs/ # Documentation pages
β β β βββ page.tsx # EIP-7702 specification
β β βββ reference/ # Code reference pages
β β β βββ page.tsx # Examples & tutorials
β β βββ layout.tsx # Root layout
β β βββ globals.css # Global styles
β βββ components/ # React components
β β βββ dashboard.tsx # Main dashboard with 4 tabs
β β βββ batch-transaction-enhanced.tsx # Batch transaction with templates
β β βββ batch-result-checker.tsx # Check batch results
β β βββ transaction-history.tsx # Transaction history viewer
β β βββ enhanced-result-viewer.tsx # Transaction decoder
β β βββ gas-estimation-display.tsx # Gas estimation
β β βββ compact-header-info.tsx # Account info header
β β βββ delegation/ # Delegation components
β β β βββ revoke-delegation-button.tsx
β β β βββ steps.tsx
β β βββ providers/ # Context providers
β β βββ ui/ # UI components (shadcn)
β βββ hooks/ # Custom React hooks
β β βββ use-batch-calls.ts # Batch transaction logic
β β βββ use-delegation-status.ts # Check delegation status
β β βββ use-revoke-delegation.ts # Revoke delegation
β β βββ use-gas-estimation.ts # Gas estimation
β β βββ use-transaction-history.ts # Transaction history
β βββ lib/ # Utilities & config
β β βββ wagmi.ts # Wagmi configuration
β β βββ utils.ts # Helper functions
β β βββ batch-templates.ts # Preset templates
β β βββ transaction-decoder.ts # Function decoder
β β βββ supported-chains.ts # Chain configurations
β β βββ abis/ # Contract ABIs
β βββ types/ # TypeScript types
βββ README.md
- Node.js >= 18.0.0
- pnpm >= 8.0.0
- Git
# Clone repository
git clone <your-repo-url>
cd eip-7702
# Install dependencies
pnpm install
# Copy environment template
cp .env.local.example .env.local
# Get free Alchemy API key: https://www.alchemy.com/
# Update .env.local with your keys:
# NEXT_PUBLIC_SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY_HERE
# Contract addresses are pre-configured for Sepolia
# Start development server
pnpm dev
- Open http://localhost:3000
- Connect MetaMask wallet
- Switch to Sepolia testnet
- Get test ETH from Sepolia Faucet
- Go to "Batch Transactions" tab
- Choose a template or create custom transactions
- Review gas estimation
- Click "Execute Batch"
- MetaMask prompts: "Upgrade to Smart Account?" β Approve
- All transactions execute atomically! π
- Check result in "Check Result" tab or on Etherscan
That's it! No manual authorization needed - MetaMask handles everything!
- Go to "Transaction History" tab
- View all past batch transactions
- Search and filter by status or date
- Click on any transaction to see decoded details
- Export/Import history as JSON
- Go to "Info" tab
- View current delegation status
- See delegated contract address (if delegated)
- Click "Revoke Delegation" to reset to normal EOA
- Confirm transaction in MetaMask
- Account reverted to normal EOA! π
Alternative Methods:
- Use hook:
const { revokeDelegation } = useRevokeDelegation()
- MetaMask UI: Account Details β Switch to EOA
- See full guide: .docs/revoke-delegation-guide.md
Address: 0x63c0c19a282a1b52b07dd5a65b58948a07dae32b
(Sepolia)
Contract used in real EIP-7702 transactions on Sepolia:
- Stateless Design: No contract storage, lower gas costs
- Simple & Efficient: Single execute function with Execution struct
- Battle-tested: Used in production transactions
- ERC-7579 Compatible: Follows Module standard
struct Execution {
address target;
uint256 value;
bytes callData;
}
function execute(Execution calldata _execution) external payable;
- Next.js 15 with App Router
- React 19 with Server Components
- Viem 2.37.12 for EIP-7702 support
- Wagmi 2.x for wallet management
- Tailwind CSS + Radix UI for styling
- shadcn/ui for component library
- β Ethereum Mainnet (Chain ID: 1)
- β BNB Smart Chain (Chain ID: 56)
- β BNB Smart Chain Testnet (Chain ID: 97)
- β Mega Testnet (Chain ID: 10008)
- β Base Mainnet (Chain ID: 8453)
- β Arbitrum One (Chain ID: 42161)
- β Sepolia Testnet (Chain ID: 11155111)
- π¦ MetaMask Only - Optimized for MetaMask wallet
- No WalletConnect or other connectors
- MetaMask automatically handles EIP-7702 authorization
- Home /: Interactive demo with batch transactions
- Docs /docs: Complete EIP-7702 specification and guides
- Reference /reference: Code examples, tutorials, and best practices
- Dashboard: Main interface with 4 tabs (Batch Transactions, Check Result, Transaction History, Info)
- BatchTransactionEnhanced:
- Create multiple transaction calls
- 8 preset templates for common use cases
- Gas estimation before execution
- Auto sign authorization + encode + send
- Atomic execution (all or nothing)
- Uses
useSendCalls
hook (ERC-5792)
- BatchResultChecker: Check status and results of batch transactions
- TransactionHistory:
- View all past transactions
- Search and filter capabilities
- Export/Import as JSON
- Statistics dashboard
- EnhancedResultViewer:
- Decode 50+ common function signatures
- Transaction details with gas usage
- Visual timeline of execution
- Etherscan integration
- RevokeDelegationButton: Component for revoking delegation
- Status display with delegated address
- Revoke button with loading states
- Success/Error messages
- Etherscan links
- CompactHeaderInfo: Display address, balance, network info
- WalletConnect: MetaMask connection with network detection
- useBatchCalls: Main hook for batch transactions
- Uses wagmi's
useSendCalls
(ERC-5792) - Automatic authorization handling
- Transaction status tracking
- Uses wagmi's
- useRevokeDelegation: Revoke delegation logic
- Multiple revoke methods (Viem, Contract)
- Delegation status checking
- Error handling with helpful messages
- Transaction tracking
- useDelegationStatus: Check delegation state
- Check if account is delegated
- Get delegated contract address
- Auto-refresh capabilities
- useGasEstimation: Estimate gas costs
- Compare batch vs sequential execution
- Calculate gas savings
- Display estimated costs
- useTransactionHistory: Manage transaction history
- Auto-save transactions to localStorage
- Search and filter capabilities
- Export/Import as JSON
β Complete EIP-7702 Flow:
- Sign authorization β 2. Encode call data β 3. Send type 0x04 tx β 4. Verify on Etherscan
β Error Handling: Comprehensive error messages and recovery flows
β Network Detection: Auto-detect wrong network and prompt switch
β Loading States: Visual feedback for async operations
β Transaction Tracking: Links to Etherscan for all transactions
# Install all dependencies
pnpm install
# Development server
pnpm dev
# Build for production
pnpm build
# Start production server
pnpm start
# Lint code
pnpm lint
# Type check
pnpm type-check
# Clean build artifacts
pnpm clean
- Push your code to GitHub/GitLab/Bitbucket
- Go to vercel.com
- Click "Import Project"
- Select your repository
- Configure environment variables:
NEXT_PUBLIC_SEPOLIA_RPC_URL
NEXT_PUBLIC_PIMLICO_API_KEY
(optional, for EIP-7710)
- Click "Deploy"
- Done! Your app is live π
# Install Vercel CLI globally (if not installed)
pnpm add -g vercel
# Login to Vercel
vercel login
# Build and deploy to production
pnpm build
vercel --prod
# Or deploy preview (for testing)
vercel
Go to your project settings β Environment Variables and add:
NEXT_PUBLIC_SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY
NEXT_PUBLIC_PIMLICO_API_KEY=your_pimlico_api_key
Note: Environment variables with NEXT_PUBLIC_
prefix are exposed to the browser.
pnpm build
# Deploy .next folder
# Build application
pnpm build
# Start production server
pnpm start
# Or use PM2 for process management
pm2 start pnpm --name "eip-7702" -- start
- Ensure all environment variables are set
- Test thoroughly on Sepolia testnet first
- Monitor gas costs and transaction success rates
- Set up error tracking (e.g., Sentry)
- Configure proper CORS and security headers
- β Transaction confirmation UIs
- β Input sanitization and validation
- β Secure signature handling
- β Clear user prompts for all actions
- β Network validation before transactions
-
MetaMask not prompting for authorization
- Ensure you're on a supported network (Sepolia recommended)
- Update MetaMask to latest version
- Try refreshing the page and reconnecting wallet
-
Batch transaction fails
- Check gas limits and balances
- Verify all transaction calls are valid
- Review error messages in Check Result tab
-
Cannot revoke delegation
- Ensure account is actually delegated (check Info tab)
- Try different revoke methods (see revoke guide)
- Check network connection and gas balance
-
Gas estimation showing N/A
- Some networks may not support gas estimation
- Transaction will still work, just estimate manually
- Check console for detailed errors
# Check build issues
pnpm build
# View detailed error logs
pnpm dev
# Then check browser console (F12)
# Clear Next.js cache
rm -rf .next
pnpm dev
- Fork repository
- Create feature branch
- Follow code standards in
.copilot.instructions.md
- Test your changes thoroughly
- Submit pull request with clear description
MIT License - see LICENSE file for more details.