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
| Scenario | Authorizations | Empty Accounts | Gas Cost |
|---|---|---|---|
| Single (empty) | 1 | 1 | 37,500 |
| Single (not empty) | 1 | 0 | 12,500 |
| Batch of 5 (all empty) | 5 | 5 | 187,500 |
| Batch of 5 (none empty) | 5 | 0 | 62,500 |
| Batch of 10 (5 empty) | 10 | 5 | 250,000 |
Cost per Authorization
| Empty Accounts | Gas per Auth |
|---|---|
| All empty | 37,500 |
| None empty | 12,500 |
| 50% empty | 25,000 (average) |
| 25% empty | 18,750 (average) |
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

