Access history within a transaction can affect some resource costs.
LET’S PICTURE IT
Opening a cabinet for the first time can require more setup than looking again while it is already in use.
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.
Some accesses have a tracked context
Ethereumgas rules distinguish cold and warm access for relevant accounts or storage locations. The first qualifying access and subsequent accesses can therefore have different costs.
The scope is transaction execution
Warmness is not a promise that a server’s operating-system cache was recently used. It is protocol-defined accounting. A new transaction has its own relevant starting context under the rules.
Access lists can supply information
Certain transaction formats can name accounts and storage keys in advance, with specified charges and effects. An access list is not universally a free optimization; compare the full costs and actual usage.
Avoid one-cost mental models
Saying every storage read costs one fixed amount can miss the context. The primary EIP describes the detailed rules, including how execution scope and reversions interact with tracked accesses.