StorageSlotString
StorageSlotString
Library for reading and writing strings to specific storage slots. Example usage to set ERC1967 implementation slot:
contract ERC1967 {
bytes32 internal constant _CONTRACT_URI_SLOT = keccak256('CONTRACT_URI');
function contractURI() public view returns (string memory) {
return StorageSlotString.getStringSlot(_CONTRACT_URI_SLOT).value;
}
function setContractURI(string memory uri) external onlyRole(CONTRACT_URI_ROLE) {
StorageSlotString.getStringSlot(_CONTRACT_URI_SLOT).value = uri;
}
}
StringSlot
struct StringSlot {
string value;
}
getStringSlot
function getStringSlot(bytes32 slot) internal pure returns (struct StorageSlotString.StringSlot r)
Returns an StringSlot
with member value
located at slot
.