Skip to content

Latest commit

 

History

History
23 lines (22 loc) · 1.21 KB

Storage Layout & Ordering.md

File metadata and controls

23 lines (22 loc) · 1.21 KB

Ordering of storage variables and struct members affects how they can be packed tightly.

For example, declaring your storage variables in the order of uint128, uint128, uint256 instead of uint128, uint256, uint128, as the former will only take up two slots of storage whereas the latter will take up three.


Slide Screenshot

120.jpg


Slide Text

  • State Vars Ordering
  • Declaration -> Packing
  • Packing -> Gas Costs
  • SLOADs & SSTOREs
  • uint128, uint128, uint256
    • Two Storage Slots
  • uint128, uint256, uint128
    • Three Storage Slots

References


Tags

Storage, Stack Memory, Storage, and Flow Operations, Storage Layout, Storage Packing, [Storage Layout & Inheritance], Storage Layout for Mappings & Dynamic Arrays