โ Blockchain & Smart Contracts (Solidity) learning pathBlockchain & Smart Contracts (Solidity) ยท Module 5 of 10
Data structures and storage
Store data efficiently on-chain.
๐ Key ideas
- Mappings: mapping(address => uint256) balances;
- Arrays and structs group data.
- Data locations: storage (persistent), memory (temporary), calldata (read-only input).
- Storage writes are expensive in gas.
- Avoid unbounded loops over large arrays.
๐ก Real-life example: Storage is writing in a permanent register; memory is scribbling on scratch paper.
mappingKey-value store
structCustom grouped type
storagePersistent contract data
calldataRead-only function input