I am learning to write a proxy contract in Solidity
.
What do we mean by collision when writing proxy contract for a smart contract?
I have some other questions as well , pls refer to comments inside this code snippet.
contract Proxy {
// slots to prevent collision ( idk what it actually means )
bytes32 public constant IMPLEMENTATION_SLOT = bytes32( // slot for implementation contract ( this slot stores address of implementation contract )
uint(keccak256("eip1967.proxy.implementation")) - 1 // can I write anything instead of eip1967.proxy.implementation here ? What exactly is the meaning of this line ?
);
bytes32 public constant ADMIN_SLOT = bytes32( // slot for admin contract ( this slot stores address of admin contract )
uint(keccak256("eip1967.proxy.admin")) - 1 // can I write anything instead of eip1967.proxy.admin here ? What exactly is the meaning of this line ?
);
);
// rest of the code here
}
library StorageSlot {
struct AddressSlot {
address value;
} // why is the value stored inside AddressSlot struct and not just simply as normal variable address value ?
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
} // what does this code inside assembly do ?
}
}