Try it Live
Run Authorization examples in the interactive playground
Gas Calculations
Calculate gas costs for EIP-7702 authorizations.Overview
EIP-7702 authorization processing has two gas cost components:- Base cost per authorization: 12,500 gas
- Empty account cost: 25,000 gas (if delegated address is empty)
(authCount * 12500) + (emptyCount * 25000)
Constants
calculateGasCost
Calculate total gas cost for authorization list.authList: Array of authorizationsemptyAccounts: Number of empty accounts being delegated to
(authList.length * 12500) + (emptyAccounts * 25000)
Usage
Examples
All empty accounts:getGasCost
Calculate gas cost for single authorization.auth: Authorization to calculate cost forisEmpty: Whether delegated address is empty
- If empty:
12500 + 25000 = 37500 - If not empty:
12500
Usage
Empty Account Detection
What is an Empty Account?
An account is considered empty if:- Balance = 0
- Nonce = 0
- Code length = 0
- Storage is empty
Checking if Account is Empty
Counting Empty Accounts
Gas Estimation Patterns
Pre-transaction Estimation
Estimate gas before sending transaction:With Gas Limit
Check if within gas limit:Per-Authorization Cost Breakdown
Calculate cost for each authorization:Optimization Strategies
Minimize Empty Account Delegations
Empty accounts cost more gas. Prefer delegating to deployed contracts:Batch Size Optimization
Larger batches have better gas efficiency per authorization:Deduplication
Remove duplicate delegations to save gas:Gas Cost Tables
Base Costs
Cost per Authorization
Advanced Patterns
Dynamic Gas Pricing
Adjust authorization list based on gas price:Gas Budget Allocation
Allocate gas budget across authorization types:Gas Monitoring
Track gas usage during processing:Testing
Test Gas Calculations
Performance
Gas calculation is O(1):See Also
- Processing - Authorization processing
- EIP-7702 - Gas specification
- Validation - Pre-processing validation

