Try it Live
Run AccessList examples in the interactive playground
Queries
Operations for inspecting AccessList contents.AccessList.includesAddress()
Check if address exists in access list.list: Access list to searchaddress: Address to find
true if address is in list
Example:
AccessList.includesStorageKey()
Check if storage key exists for address.list: Access list to searchaddress: Address to checkkey: Storage key to find
true if key exists for address
Example:
- Returns
falseif address not in list - Returns
falseif address has no storage keys - O(n×m) complexity: searches addresses then keys
AccessList.keysFor()
Get all storage keys for an address.list: Access list to searchaddress: Address to get keys for
undefined if address not in list
Example:
- Returns
undefinedif address not found (not empty array) - Returns reference to internal array (readonly)
- May return empty array if address has no keys
AccessList.addressCount()
Count total addresses in list.list: Access list to count
- Counts all addresses, including duplicates
- O(1) operation (array length)
AccessList.storageKeyCount()
Count total storage keys across all addresses.list: Access list to count
- Sums all keys across all addresses
- Includes duplicates
- O(n) operation
AccessList.isEmpty()
Check if access list is empty.list: Access list to check
true if list has no items
Example:
- Checks only top-level array length
- Does not check if items have storage keys
- O(1) operation
Patterns
Check Before Adding
Iterate All Keys
Count Analysis
Conditional Building
Find Missing Keys
List Summary
Validate Completeness
Performance
| Operation | Complexity | Notes |
|---|---|---|
| includesAddress | O(n) | n = addresses |
| includesStorageKey | O(n×m) | Byte comparison |
| keysFor | O(n) | Finds first match |
| addressCount | O(1) | Array length |
| storageKeyCount | O(n) | Sum all keys |
| isEmpty | O(1) | Length check |
- Cache results if querying multiple times
- Use
includesAddressbeforeincludesStorageKey - Deduplicate before counting for accurate metrics
Best Practices
-
Check before adding to avoid duplicates
-
Handle undefined return from keysFor
-
Use isEmpty for conditional logic
-
Count before processing
-
Cache query results
See Also
- Manipulation - Modifying lists
- Validation - Type guards
- Gas Optimization - Cost analysis

