This repository is forked from the QuickNode EIP-7702 Guide Examples and contains implementations for account abstraction using EIP-7702.
EIP-7702 introduces account abstraction by allowing Externally Owned Accounts (EOAs) to temporarily delegate their execution to smart contract code. This repository has this functionality through the BatchCallAndSponsor contract, which enables:
- Gasless transactions sponsored by third parties
- Batch execution of multiple calls in a single transaction
- Signature-based authorization for enhanced security
- Replay protection through nonce management
- Foundry toolkit
- Node.js (for environment variable management)
- Access to EIP-7702 compatible networks
git clone <this-repo>
cd gasless-transactions
forge install
$curl -L https://foundry.paradigm.xyz | bash
$ foundryup
#if needed
$ git rm --cached foundry
$ rm -rf .git/modules/foundry
$ cat .gitmodules
$ forge install foundry-rs/forge-std
$ forge install OpenZeppelin/openzeppelin-contracts
$ ls -la lib/
#
$ forge buildcp env.template .env
# Edit .env with your private keys and RPC URLs# Deploy to Sepolia testnet
sh deploy network --sepolia
# Deploy to Base mainnet
sh deploy network --base
# Deploy to local network
sh deploy network --localhost# Terminal 1 if needed inside the foundry folder
cd foundry
run : ./target/release/anvil --hardfork prague --chain-id 31337
# Terminal 2
cd ..
source .env
# run step 3 Deploy Contract or run below script.
forge script script/DeployBatchCallAndSponsor.s.sol:DeployBatchCallAndSponsor --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY -vvvv
forge build
forge script script/SendSponsoredEIP7702Transaction.s.sol:SendSponsoredEIP7702Transaction --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast -vvvv
forge script script/CheckDelegationStatus.s.sol:CheckDelegationStatus --rpc-url $SEPOLIA_RPC_URL -vvv
forge script script/RemoveDelegation.s.sol:RemoveDelegation --rpc-url $SEPOLIA_RPC_URL -vvv --broadcast# Terminal 1 if needed inside the foundry folder
cd foundry
run : ./target/release/anvil --hardfork prague --chain-id 31337
# Terminal 2
cd backend
run : npm start
# Terminal 2
cd ui
run : python3 -m http.server 3000
# ui is accessible on port localhost:3000The main contract (src/BatchCallAndSponsor.sol) provides two execution methods:
- Signature-based execution: Any sponsor can submit batched calls with valid signatures
- Direct execution: The account itself can execute calls without signatures
- β Nonce-based replay protection
- β ECDSA signature verification
- β Batch call execution
- β Comprehensive event logging
The deployment script supports the following networks:
| Network | Chain ID | Key |
|---|---|---|
| Ethereum Mainnet | 1 | mainnet |
| Sepolia Testnet | 11155111 | sepolia |
| Polygon Mainnet | 137 | polygon |
| Base Mainnet | 8453 | base |
| BSC Mainnet | 56 | bsc |
| Localhost (Anvil) | 31337 | localhost |
gasless-transactions/
βββ src/
β βββ BatchCallAndSponsor.sol # Main EIP-7702 contract
βββ script/
β βββ DeployBatchCallAndSponsor.s.sol # Deployment script
β βββ addressBook/ # Per-chain contract addresses
β βββ 1.json # Ethereum Mainnet addresses
β βββ 11155111.json # Sepolia Testnet addresses
β βββ 137.json # Polygon Mainnet addresses
β βββ 8453.json # Base Mainnet addresses
β βββ 56.json # BSC Mainnet addresses
βββ test/ # Test files
βββ deploy # Network deployment script
βββ env.template # Environment variables template
βββ foundry.toml # Foundry configuration
forge build # Compile contracts
forge test # Run tests
forge test -vvv # Run tests with verbose output# Run Slither with custom configuration
slither . --config-file .slither.config.json
# Run Slither with default settings
slither .
# Get help with Slither commands
slither --help
# Run Slither and save output to file
slither . --config-file .slither.config.json --json reports/slither-report.jsonNote: The project includes a
.slither.config.jsonfile that excludes library dependencies and low-severity findings for cleaner output. Reports are automatically saved toreports/slither-report.json.
sh deploy network --sepolia # Deploy to Sepolia
sh deploy network --polygon # Deploy to Polygon
sh deploy network --base # Deploy to BaseThe project uses a per-chain addressBook system where each network has its own JSON file containing deployed contract addresses:
# View addresses for specific networks
cat script/addressBook/1.json # Ethereum Mainnet
cat script/addressBook/11155111.json # Sepolia Testnet
cat script/addressBook/137.json # Polygon Mainnet
cat script/addressBook/8453.json # Base Mainnet
cat script/addressBook/56.json # BSC MainnetPRIVATE_KEY=your_private_key_here
SEPOLIA_RPC_URL=https://eth-sepolia.alchemyapi.io/v2/YOUR_KEY
POLYGON_RPC_URL=https://polygon-mainnet.alchemyapi.io/v2/YOUR_KEY
BASE_RPC_URL=https://base-mainnet.alchemyapi.io/v2/YOUR_KEY
BSC_RPC_URL=https://bsc-dataseed.binance.org- β Automatic network detection based on chain ID
- β Per-chain address book management with separate JSON files
- β
Environment variable loading from
.env - β Cross-platform compatibility
- β Automatic address book updates after deployment
- Original Implementation: QuickNode EIP-7702 Guide
- EIP-7702 Specification: ethereum/EIPs
- Foundry Documentation: book.getfoundry.sh
This is an internal development repository for educational and testing purposes. The contracts are experimental and should not be used in production without thorough security audits.
MIT License - see LICENSE file for details.