This repository contains two different implementations of proxy airdrop contracts.
File: contracts/ProxySponsor_OPTION1.sol
A streamlined proxy contract focused solely on efficient airdrop operations without additional complexity.
- ✅ Smart Airdrop Logic - Prevents over-funding by checking receiver balance
- ✅ Gas Cost Calculation - Dynamic gas cost calculation for optimal transfers adding approve and stake txs
- ✅ Gas Cost Coefficient - Configurable multiplier for gas cost calculations (default: 105%)
- ✅ Minimum Transfer Value - Configurable minimum airdrop amounts
constructor(address _dedicatedMsgSender)
File: contracts/ProxySponsor.sol
A comprehensive proxy contract with advanced features including gasless transactions and staking capabilities.
- ✅ Smart Airdrop Logic - Prevents over-funding by checking receiver balance
- ✅ Gas Cost Calculation - Dynamic gas cost calculation for optimal transfers only considering approve
- ✅ Gas Cost Coefficient - Configurable multiplier for gas cost calculations (default: 105%)
- ✅ Minimum Transfer Value - Configurable minimum airdrop amounts
- ✅ Gasless USDC Staking - Integration with external USDC staking contracts
- ✅ Gasless ETH Staking - Integration with external ETH staking contracts
constructor(
address _dedicatedMsgSender,
address _trustedForwarder,
address _stakeContractUSDC,
address _stakeContractETH
)
Both contracts maintain:
owner
- Contract administratordedicatedMsgSender
- Authorized airdrop callerminimumTransferValue
- Minimum ETH transfer amountgasCostCoefficient
- Gas cost multiplier in basis points (default: 10500 = 105%)gasApprove
- Gas units for approve operation (default: 40000)
ProxySponsor_OPTION1 Additional:
gasStake
- Gas units for stake operation (default: 140000)
function airdrop(address receiver, uint256 gasPrice) external onlyDedicatedMsgSender
- Transfers ETH to receiver based on provided gas price and gas costs or minimum value
- Prevents over-funding by checking receiver's current balance
- Only callable by the dedicated message sender
- Validates that gas price is not zero
function setMinimumTransferValue(uint256 _minimumValue) external onlyOwner
function setGasCostCoefficient(uint256 _coefficient) external onlyOwner
function setGasApprove(uint256 _gasApprove) external onlyOwner
function changeDedicatedMsgSender(address _newDedicatedMsgSender) external onlyOwner
function changeOwner(address _newOwner) external onlyOwner
function withdraw() external onlyOwner
ProxySponsor_OPTION1 Additional:
function setGasStake(uint256 _gasStake) external onlyOwner
npm install
npx hardhat compile
# Test both contracts
npx hardhat test --network hardhat
# Test specific contract
npx hardhat test test/proxy-sponsor.ts --network hardhat
npx hardhat test test/proxy-sponsor-option1.ts --network hardhat
- ProxySponsor_OPTION1: 36 tests covering core functionality
- ProxySponsor_OPTION2: 42 tests covering all features
- ✅ Access Control - Proper modifier usage
- ✅ Reentrancy Protection - No external calls in critical functions
- ✅ Input Validation - Comprehensive parameter checks
- ✅ Custom Errors - Gas-efficient error handling
- ✅ ERC2771 Security - Trusted forwarder validation
- ✅ Staking Integration - External contract validation
- ✅ Advanced Admin - Stake contract management
MIT