Skip to main content
This page is a placeholder. All examples on this page are currently AI-generated and are not correct. This documentation will be completed in the future with accurate, tested examples.

Overview

Opcode: 0x54 Introduced: Frontier (EVM genesis) Updated: Berlin (EIP-2929, cold/warm tracking) SLOAD reads a 256-bit value from an account’s persistent storage. The gas cost depends on whether the storage slot was previously accessed in the transaction (warm) or not (cold). This operation is essential for reading contract state: balances, permissions, prices, and any data that must persist across transactions.

Specification

Stack Input:
Stack Output:
Gas Cost:
  • 100 gas - Warm access (already accessed in transaction)
  • 2100 gas - Cold access (first access, EIP-2929)
Operation:

Behavior

SLOAD retrieves the current value stored at a key in the calling contract’s account storage:
  1. Pop key from stack (256-bit unsigned integer)
  2. Query host for storage value at contract address + key
  3. Return value from host (0 if slot never written or cleared)
  4. Push result to stack
  5. Track access for cold/warm metering (EIP-2929)
  6. Increment PC

Cold vs Warm Access

First access in transaction (cold): 2100 gas
Subsequent accesses (warm): 100 gas
Access list (EIP-2930): Can pre-warm slots

Uninitialized Slots

Slots never written return 0:

Examples

Basic Storage Read

Cold Access Tracking

Mapping Access

Nested Structures

Gas Cost

Cost Matrix:
Access TypeGasEIPNotes
Warm100EIP-2929Seen before in transaction
Cold2100EIP-2929First access in transaction
Pre-warmed100EIP-2930Via access list
Optimization: SLOAD is ~21x more expensive on cold access. Batch accesses or use access lists for known storage reads.

Edge Cases

Uninitialized Slot

Max Uint256 Value

Stack Boundaries

Insufficient Gas

Common Usage

State Variable Access

Mapping Lookups

Multi-Read Optimization

Access List Warm-up

Implementation

Testing

Test Coverage

Security

State Immutability During Reads

SLOAD is read-only and safe in any context (even static calls). It cannot modify state, only query it:

Reentrancy Vulnerability (When Used with State Changes)

SLOAD itself is safe, but reading and then writing creates reentrancy windows:

Access List Validation

Ensure access lists match actual storage accessed:

Gas Cost Variation

Cold/warm access affects gas accounting for batch operations:

Benchmarks

Access cost comparison:
  • Warm SLOAD: 100 gas
  • Cold SLOAD: 2100 gas (21x more expensive)
  • MLOAD (memory): 3 gas (67x cheaper than warm)
  • L1 cache: ~0.5ns vs ~100ns for cold storage
Practical implications:

References