0PricingLogin
Web3 & DApp Development Fundamentals · Lesson

Storage, Memory, Stack

EVM data locations.

Where Data Lives in the EVM

The EVM has several distinct places to keep data, each with different costs and lifetimes.

The three core data locations are the stack, memory, and storage. Choosing the right one is key to writing efficient contracts.

The Stack

The stack is the EVM's scratchpad for computation. It holds up to 1024 values of 256 bits each.

Opcodes push and pop from the top of the stack. It is extremely cheap but tiny and temporary.

PUSH1 0x02   // [2]
PUSH1 0x04   // [2, 4]
MUL          // [8]
// stack vanishes when the call ends

All lessons in this course

  1. The Ethereum Virtual Machine
  2. Storage, Memory, Stack
  3. Opcodes
  4. Accounts and State
← Back to Web3 & DApp Development Fundamentals