A Next.js demo application showcasing EIP-7702 authorization with Privy embedded wallets and Permissionless SDK for gasless transactions. This app enables users to upgrade their EOA (Externally Owned Account) to behave like a smart account using EIP-7702, allowing them to send sponsored transactions through Pimlico bundler/paymaster services.
- EIP-7702 Account Abstraction: Transform EOAs into smart accounts temporarily
- Privy Integration: Secure embedded wallet management and authentication
- Gasless Transactions: Sponsored transactions via Pimlico paymaster
- ERC-20 Gas Payments: Pay transaction fees using USDC tokens
- Secure API Proxy: Hide Pimlico API keys from frontend exposure
- Cloud Deployment: Standalone proxy server for production use
Frontend (Next.js) β Proxy Server β Pimlico API
β
Sepolia Testnet
- Frontend: React components with Privy wallet integration
- Proxy Layer: Secure API key management and request forwarding
- Smart Account: EIP-7702 enabled account abstraction
- Paymaster: Pimlico service for transaction sponsorship
# Install dependencies
pnpm install
# Copy environment variables
cp .env.example .env.local# Privy Configuration
NEXT_PUBLIC_PRIVY_APP_ID=your_privy_app_id
# Pimlico Configuration (Server-side only)
PIMLICO_API_KEY=pim_your_actual_api_key
# Network Configuration
NEXT_PUBLIC_SEPOLIA_RPC_URL=https://1rpc.io/sepolia
# Optional: Sponsorship Policy
NEXT_PUBLIC_SPONSORSHIP_POLICY_ID=sp_your_policy_id
# Proxy Configuration
NEXT_PUBLIC_PIMLICO_PROXY_URL=http://localhost:3000/api/pimlico-proxy
# For production: http://your-server:8081/pimlico-proxy# Start development server
pnpm dev
# Code formatting
pnpm format
# Linting
pnpm lint
# Build for production
pnpm buildThe built-in API route at /api/pimlico-proxy.ts provides a simple proxy for development.
For production deployments, use the independent Express server:
cd src/proxy
# Install dependencies
npm install
# Start server
npm start
# Or with PM2 for production
npm run pm2# On your cloud server
git clone [your-repo]
cd permissionless-privy-7702/src/proxy
# Install dependencies
npm ci --only=production
# Set environment variables
echo "PIMLICO_API_KEY=your_key" > .env
echo "PROXY_PORT=8081" >> .env
echo "ALLOWED_ORIGINS=https://yourdomain.com" >> .env
# Start with PM2
npm run pm2cd src/proxy
docker build -t pimlico-proxy .
docker run -p 8081:8080 -e PIMLICO_API_KEY=your_key pimlico-proxy- β API keys stored server-side only
- β Frontend never exposes sensitive credentials
- β Transparent proxy maintains SDK compatibility
- β CORS protection with configurable origins
- β Request size limiting
- β Error handling and logging
- β Rate limiting (recommended)
- β Request filtering
- β Health check endpoints
// The UserOperation component handles:
// 1. Privy authentication
// 2. Smart account creation
// 3. EIP-7702 authorization signing
// 4. Transaction submission// Send sponsored transaction
await smartAccountClient.sendTransaction({
calls: [{
to: zeroAddress,
data: "0x",
value: BigInt(0)
}],
factory: '0x7702',
factoryData: '0x',
paymasterContext: {
sponsorshipPolicyId: process.env.NEXT_PUBLIC_SPONSORSHIP_POLICY_ID
},
authorization
})// Pay gas with USDC tokens
await smartAccountClient.sendTransaction({
calls: [
{
to: USDC_TOKEN,
abi: parseAbi(["function approve(address,uint256)"]),
functionName: "approve",
args: [paymaster, maxUint256]
},
{
to: targetContract,
data: "0x1234"
}
],
paymasterContext: {
token: USDC_TOKEN
},
authorization
})- Authentication: User logs in via Privy embedded wallet
- Account Setup: Create smart account client with EIP-7702 support
- Authorization: Sign EIP-7702 authorization to upgrade EOA
- Transaction: Submit UserOperation with authorization
- Execution: Pimlico processes and sponsors the transaction
# View detailed request logs
pnpm dev
# Check proxy server logs
cd src/proxy && npm run dev# PM2 logs
pm2 logs pimlico-proxy
# Docker logs
docker logs [container-id]
# Health check
curl http://your-server:8081/health"No wallet found" Error
# Solution: Ensure Privy embedded wallet is properly initialized
# Check: embeddedWallet?.address is availableCORS Errors
# Solution: Configure ALLOWED_ORIGINS in proxy server
ALLOWED_ORIGINS=https://yourdomain.com,http://localhost:3000Transaction Failures
# Check: Sufficient USDC balance for gas payments
# Check: Valid EIP-7702 authorization signature
# Check: Correct nonce (use EOA nonce, not smart account nonce)Proxy Connection Issues
# Verify: NEXT_PUBLIC_PIMLICO_PROXY_URL points to running server
# Check: Firewall settings allow traffic on proxy port- Connect wallet via Privy
- Send regular 7702 transaction
- Send gasless test transaction
- Send USDC gas payment transaction
- Verify transactions on Sepolia Etherscan
- Testnet: Sepolia
- Test ETH: Required for account setup
- Test USDC: Required for ERC-20 gas payments
- Faucets: Sepolia Faucet
- Framework: Next.js 15 with React 19
- Authentication: Privy embedded wallets
- Account Abstraction: Permissionless SDK + EIP-7702
- Blockchain: Ethereum Sepolia testnet
- Bundler/Paymaster: Pimlico services
- Styling: Tailwind CSS + shadcn/ui
- Proxy: Express.js (standalone) / Next.js API routes
- EIP-7702 Specification - Official EIP-7702 standard specification
- Privy Documentation - Complete Privy integration guide
- Permissionless SDK - Account abstraction SDK documentation
- Pimlico Documentation - Bundler and paymaster service docs
- Sepolia Testnet - Ethereum testnet explorer
- π οΈ Permissionless + Privy + 7702 Example - Official starter repository and complete implementation reference
- π Privy EIP-7702 Authorization Guide - How to sign 7702 authorizations with Privy React hooks
- π Privy EIP-7702 Recipe - Step-by-step integration recipe for Privy + Pimlico + EIP-7702
- π° USDC Gas Payment Tutorial - Using ERC-20 tokens for transaction gas fees
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This is a demo application for educational purposes. Do not use in production without proper security audits and testing. Always verify transactions and smart contract interactions before deployment.