Skip to content
storage

Storage & Persistence

The permanent state of a contract.

Storage is a persistent key-value store that lasts forever on the blockchain. It maps 256-bit keys to 256-bit values. Every smart contract has its own isolated storage area. Writing to storage (SSTORE) is one of the most expensive operations in the EVM because every node in the network must store that data indefinitely.

Execution Simulation

Assistant Note

"Currently at PUSH instruction. It's going to place a value on top of the stack."

Program

5 bytes
0000
PUSH10xff
Place 1-byte item on stack
0002
PUSH10x00
0004
SSTORE

Stack

LIFO
0 / 1024
Stack is empty

Most opcodes pop their arguments from here.

Storage

Persistent
Storage is empty

Use SSTORE to persist data across transactions.

Storage is a key-value store. In Solidity, variables are mapped to slots (0, 1, 2...) or hashed for mappings/arrays.

Gas Meter

Consumed0 / 1,000,000
Last Op Cost
-0
Refund
0
* Gas prevents infinite loops and DDoS. SSTORE is the most expensive opcode (20,000 gas for new slots).