lessonΒ·25 minΒ·Chapter 3 of 3
Storage vs Memory vs Calldata
Data location matters in Solidity: Storage is persistent (on-chain), like a hard drive β writes cost significant gas. Memory is temporary, exists only during function execution β like RAM. Calldata is read-only, used for function parameters in external calls β cheapest option. Reference types (arrays, structs, mappings) must specify their data location. Using `calldata` for read-only function parameters saves gas compared to `memory` because no copy is made.
π‘ Key Takeaway
This lesson covers the fundamental concepts. Make sure you understand these before moving to the next chapter.