Choose a Scenario
Execution Pipeline
1
SSTORECold write: 20,000 gas
Write 42 to storage slot 0 (cold, zero → non-zero)
2
MSTOREBase cost: 3 gas
Write 42 to memory offset 0x00
Data State
Storage
Slot 0
0x0000000000000000000000000000000000000000000000000000000000000000
Memory
Offset 0x00
0x0000000000000000000000000000000000000000000000000000000000000000
Fun Fact
A single SSTORE to a new slot costs 20,000 gas — enough to run 6,667 MSTORE operations.
Why Gas-Efficient Data Location Matters
Every unnecessary storage write adds thousands of gas to your transaction costs. An ERC20 transfer needs 2 storage reads and 2 writes — roughly 14,200 gas just for state changes. Smart contracts that minimize storage operations and leverage memory for intermediate computations can save users significant ETH on every transaction. Understanding storage vs memory is one of the highest-impact gas optimizations a Solidity developer can make.