Skip to content

HappyFeet07/AlchemyGasSponsorTests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Privy Sponsor - AA Wallet with ERC-20 Gas Sponsorship

This project demonstrates how to create an Account Abstraction (AA) wallet and send sponsored transactions using ERC-20 tokens for gas payments.

Features

  1. 🎯 Create an AA wallet using Account Kit
  2. 💰 Send sponsored transactions using ERC-20 tokens (USDC) for gas
  3. 🔧 Configurable via environment variables

Setup

  1. Install dependencies:
npm install
  1. Copy environment configuration:
cp .env.example .env
  1. Update .env with your configuration:
  • ALCHEMY_API_KEY: Your Alchemy API key
  • GAS_MANAGER_POLICY_ID: Gas Manager policy ID from Alchemy dashboard
  • TOKEN_ADDRESS: ERC-20 token address (defaults to USDC on Sepolia)
  • TARGET_ADDRESS: Recipient address for the transaction
  • MAX_TOKEN_AMOUNT: Maximum token amount for safety (defaults to 10 USDC)

Usage

Run the script:

npm run start

What it does

  1. Creates an AA wallet using Account Kit and Light Account
  2. Sets up ERC-20 gas sponsorship using your Gas Manager policy
  3. 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

Configuration

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 transaction
  • MAX_TOKEN_AMOUNT: Safety limit for token spending
  • PRIVATE_KEY: Private key (auto-generated if not provided)

Output

The script will show:

  • ✅ AA wallet creation and address
  • 🚀 Transaction submission
  • 🧾 Transaction receipt with gas usage
  • 💰 ERC-20 token used for gas payment

Requirements

  • Node.js
  • Alchemy API key
  • Gas Manager policy configured in Alchemy dashboard
  • ERC-20 tokens in the wallet for gas payments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors