Try it Live
Run AccessList examples in the interactive playground
Gas Optimization
Gas cost calculation and analysis for EIP-2930 access lists.Gas Constants
AccessList.gasCost()
Calculate total gas cost for including access list in transaction.list: Access list to calculate cost for
- Upfront cost paid when transaction included
- Does not account for actual usage
- Duplicates counted separately (deduplicate first)
AccessList.gasSavings()
Calculate potential gas savings from warm vs cold access.list: Access list to calculate savings for
- Only realized if transaction actually accesses those slots
- Assumes single access per slot
- Multiple accesses to same slot increase savings
AccessList.hasSavings()
Check if access list provides net gas savings.list: Access list to check
true if savings > cost
Formula:
- Simple benefit check
- Does not account for usage patterns
- Conservative estimate (single access)
Gas Economics
When Access Lists Save Gas
Access lists are beneficial when:-
Multiple storage reads
-
Repeated accesses
-
Cross-contract interactions
When Access Lists Cost Gas
Access lists waste gas when:-
Few storage accesses
-
Already-warm slots
-
Duplicate entries
Patterns
Basic Analysis
Conditional Inclusion
Cost Comparison
Break-even Calculation
Gas Budget
Multi-access Savings
Real-World Examples
Uniswap V2 Swap
NFT Minting
Batch Transfer
Best Practices
-
Always deduplicate first
-
Don’t trust hasSavings blindly
-
Account for repeated accesses
-
Test with real transactions
-
Consider transaction type
See Also
- Queries - Inspecting lists
- Manipulation - Building lists
- Usage Patterns - Common patterns

