Understand Solidity storage layout, ABI and gas
8 steps · about 3 h · Intermediate
- Solidity value and reference types (reference, Solidity Documentation, 30 min)
Review exact bit widths, fixed vs dynamic types and data location rules before tracing how values map onto EVM words.
- Layout of state variables in storage (doc, Solidity Documentation, 25 min)
Learn 32-byte slot packing, struct alignment, inheritance order and how mappings and dynamic arrays hash their slot locations.
- Layout in memory (doc, Solidity Documentation, 15 min)
Contrast transient 32-byte-aligned memory allocation and the free memory pointer with persistent storage slots.
- Layout in calldata (doc, Solidity Documentation, 15 min)
See why read-only calldata avoids memory copies and how dynamic offsets are structured in incoming transactions.
- Contract ABI specification (reference, Solidity Documentation, 30 min)
Master 4-byte function selectors, head/tail dynamic encoding, event topic hashing and packed encoding.
- Cleaning up variables (doc, Solidity Documentation, 15 min)
Understand when the compiler inserts bit-masking instructions for types smaller than 256 bits and why that affects gas.
- The Solidity optimizer (doc, Solidity Documentation, 25 min)
Learn what the opcode and Yul optimizers rewrite, how optimizer runs trade deployment size against call gas, and what stays unchanged.
- Yul intermediate representation (doc, Solidity Documentation, 25 min)
Connect high-level Solidity storage and calldata rules to the typed assembly blocks used when auditing or tuning hot paths.