The question in the title is a little vague, so I will try to explain here.
Suppose I have a contract with a storage array:
pragma solidity 0.4.24;
contract MyContract {
uint256[10] public myArray;
constructor() public {
myArray[0] = ...;
myArray[1] = ...;
myArray[2] = ...;
myArray[3] = ...;
myArray[4] = ...;
myArray[5] = ...;
myArray[6] = ...;
myArray[7] = ...;
myArray[8] = ...;
myArray[9] = ...;
}
}
When I deploy this contract, can we say that myArray
is allocated at a specific address, and that myArray
occupies a consecutive memory block (in the example above, a block of 320 bytes) starting at that address?
If yes, is it guaranteed that no other state variable will reside at the same address range, and overlap that memory block (fully or partially)?
If the answer to all of the questions above is yes, how can I obtain the address-space (or at least the base-address) of myArray
in Solidity?
The equivalence in native languages like C or C++, when applied in Solidity, would be something like address(myArray)
, I haven't tried it, but I'm pretty sure it won't work.
Thank you!