1

Is it possible to use the name of the local variable of contract with sload code ?

contract Test {
  int a=999;
  function doIt() {
    assembly {
    sload(a);
    }
 }
}
2

Yes, although you may want to store the result of this load in a memory variable:

contract Test {
    int a = 999; // That's storage
    function doIt() {
        int b; // That's memory
        assembly {
            b := sload(a);
        }
    }
}
  • let b := sload(a) This will use stack instead of memory. Only drawback is that the variable can only be used inside the assembly block. – Nico Vergauwen Aug 22 '18 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.