Skip to main content

Try it Live

Run AccessList examples in the interactive playground
New to access lists? Start with Fundamentals for guided examples and gas cost analysis.

Type Definition

Array of items where each item specifies a contract address and storage keys to pre-warm for gas savings.
export type AccessList = readonly Item[];

export type Item = {
  address: AddressType;              // 20-byte contract address
  storageKeys: readonly HashType[];  // 32-byte storage slot keys
};

API Methods

Constructors

Type Guards

  • is - Check if value is AccessList
  • isItem - Check if value is Item
  • assertValid - Validate structure

Queries

Manipulation

Gas Analysis

Conversions

  • toBytes - Convert to RLP bytes for transaction encoding

Usage Example

Effect Schema

import { AccessListSchema } from '@tevm/voltaire/AccessList/effect'

const addr = new Uint8Array(20)
const slot = new Uint8Array(32)
const list = AccessListSchema.create().withAddress(addr).withStorageKey(addr, slot)
list.hasSavings()
import { AccessList, Address, Hash } from 'tevm';

// Create addresses and storage keys
const token = Address('0xA0b86991c6cC137282C01B19e27F0f0751D85f469e');
const balanceSlot = Hash('0x0000000000000000000000000000000000000000000000000000000000000003');

// Build access list
let list = AccessList.create();
list = list.withAddress(token);
list = list.withStorageKey(token, balanceSlot);

// Analyze gas costs
const cost = list.gasCost();
const savings = list.gasSavings();

console.log(`Cost: ${cost} gas`);       // 4,300
console.log(`Savings: ${savings} gas`); // 100

// Check if beneficial (savings > cost)
if (list.hasSavings()) {
  transaction.accessList = list;
}

Optimization

AccessList provides efficient APIs for gas analysis and manipulation.

Specification