Contract Storage
- Storage. Storage is the contract’s permanent state: slot-addressed, replicated on every node, expensive by design.
- Slots. State variables pack into 32-byte slots: layout order deciding real gas costs.
- Cold and warm access. First touch of a slot is cold and costlier: access patterns are money.
Memory and Calldata
- Memory. memory is transient scratch space per call: cheap, wiped when the call ends.
- calldata. calldata is the read-only input bytes: the cheapest place for external function arguments.
- Location keywords. Reference parameters declare a location: storage, memory or calldata: semantics, not style.
State Mutation
- Transactions mutate. State changes only inside transactions: atomic: all effects land or all revert.
- Revert semantics. A revert undoes every state change of the call: failure leaves no half-writes.
- Checks-effects-interactions. The safe order: checks, then effects, then interactions: state settled before any external call.
Before and after this level
- Before: Level 1: Solidity Foundations: Types and Variables, Functions, Contract Structure.
- Next: Level 3: Collections & Data Models: Arrays and Mappings, Structs and Enums, Designing Contract State.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Solidity Level 2: State & Data Locations cover?
Contract Storage, Memory and Calldata, State Mutation: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 1: Solidity Foundations, which covers Types and Variables, Functions, Contract Structure.