Persistent updates have costs that depend on the state transition.
LET’S PICTURE IT
Writing a new entry, overwriting an existing entry and clearing an entry can have different bookkeeping requirements.
SEE IT FOR YOURSELF
Pack small values into Solidity storage slotsStep 1 / 4
In this simple default-layout example, two uint128 values come before one uint256. Each slot holds thirty-two bytes.
In this simple default-layout example, two uint128 values come before one uint256. Each slot holds thirty-two bytes.The first sixteen-byte value occupies the low-order half of slot zero. Low-order bytes are shown on the right.The second uint128 fits in the remaining sixteen bytes. Both values now share slot zero.C needs a complete thirty-two-byte slot, so it begins at slot one. Two packed small values plus C use two slots.
Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.
Persistence is a network resource
Contract storage survives across calls and must be maintained by the system. Writing it uses gas under rules that distinguish relevant previous and new values and access context.
Not every SSTORE has the same cost
The original value, current value, new value and warm/cold status can affect metering and refunds. Counting source lines or storage assignments alone is not a complete gas calculation.
Packing changes layout, not every trade-off
Smaller adjacent values can share slots in Solidity. That can reduce slot usage, while reading or updating packed parts may require additional operations. “Smaller type” is not automatically a universal gas win.
Inspect layout and execution separately
The storage visualizer teaches slot packing for simple elementary types. It deliberately does not calculate full transactiongas or certify an upgrade layout. Use compiler output and execution evidence for production analysis.