This project demonstrates how to create an Account Abstraction (AA) wallet and send sponsored transactions using ERC-20 tokens for gas payments.
- 🎯 Create an AA wallet using Account Kit
- 💰 Send sponsored transactions using ERC-20 tokens (USDC) for gas
- 🔧 Configurable via environment variables
- Install dependencies:
npm install- Copy environment configuration:
cp .env.example .env- Update
.envwith your configuration:
ALCHEMY_API_KEY: Your Alchemy API keyGAS_MANAGER_POLICY_ID: Gas Manager policy ID from Alchemy dashboardTOKEN_ADDRESS: ERC-20 token address (defaults to USDC on Sepolia)TARGET_ADDRESS: Recipient address for the transactionMAX_TOKEN_AMOUNT: Maximum token amount for safety (defaults to 10 USDC)
Run the script:
npm run start- Creates an AA wallet using Account Kit and Light Account
- Sets up ERC-20 gas sponsorship using your Gas Manager policy
- Sends a sponsored transaction that:
- Approves the paymaster to spend ERC-20 tokens
- Executes your target transaction
- Uses USDC (or your chosen ERC-20) to pay for gas instead of ETH
The script uses these environment variables:
ALCHEMY_API_KEY: Your Alchemy API key (required)GAS_MANAGER_POLICY_ID: Your gas policy ID (required)TOKEN_ADDRESS: ERC-20 token address (default: USDC on Sepolia)TARGET_ADDRESS: Target address for transactionMAX_TOKEN_AMOUNT: Safety limit for token spendingPRIVATE_KEY: Private key (auto-generated if not provided)
The script will show:
- ✅ AA wallet creation and address
- 🚀 Transaction submission
- 🧾 Transaction receipt with gas usage
- 💰 ERC-20 token used for gas payment
- Node.js
- Alchemy API key
- Gas Manager policy configured in Alchemy dashboard
- ERC-20 tokens in the wallet for gas payments