Skip to content

Latest commit

 

History

History
25 lines (22 loc) · 1.15 KB

Storage Layout for Dynamic Arrays.md

File metadata and controls

25 lines (22 loc) · 1.15 KB

If the storage location of the array ends up being a slot p after applying the storage layout rules, this slot stores the number of elements in the array (byte arrays and strings are an exception).

Array data is located starting at keccak256(p) and it is laid out in the same way as statically-sized array data would: One element after the other, potentially sharing storage slots if the elements are not longer than 16 bytes.

Dynamic arrays of dynamic arrays apply this rule recursively.


Slide Screenshot

122.jpg


Slide Text

  • Array -> Slot p
  • Stores -> # Array Elements
  • Elements -> keccak256(p)
  • Stored Contiguously
    • Share Slots if Possible
  • Dyn Arrays -> Dyn Arrays
    • Recursively Apply

References


Tags

Keccak256, bytes & string, Storage Layout for bytes & string