โ† Blockchain & Smart Contracts (Solidity) learning path
Blockchain & Smart Contracts (Solidity) ยท Module 5 of 10

Data structures and storage

Store data efficiently on-chain.

๐Ÿ“– Key ideas

  1. Mappings: mapping(address => uint256) balances;
  2. Arrays and structs group data.
  3. Data locations: storage (persistent), memory (temporary), calldata (read-only input).
  4. Storage writes are expensive in gas.
  5. 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