Often times you'll see the following pattern for reading and writing to storage slots:

struct Slot {
  address value;


function getSlot(bytes32 slot) returns (Slot storage s) {
   assembly { s.slot := slot }

What exactly is the benefit of this? getSlot(_IMPL_SLOT).value = addr is convenient, but couldn't you also just use a simple setter:

function setSlot(address addr) {
  assembly { 
    sstore(_IMPL_SLOT.slot, addr)

What's the benefit of the struct abstraction?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.