When you go through the openbrush smart contract library. You will notice they are using upgradeable smart contract storage and while defining storage they are using some empty struct as key of similar lib name and using pub _reserved: Option<()>, in data struct.

 pub const STORAGE_KEY: u32 = openbrush::storage_unique_key!(Data)
    #[derive(Default, Debug)]
    pub struct Data {
        pub attributes: Mapping<(Id, String), String, AttributesKey>,
        pub _reserved: Option<()>,
    pub token_owner: Mapping<Id, Owner>,
    pub struct AttributesKey;
    impl<'a> TypeGuard<'a> for AttributesKey {
        type Type = &'a (&'a Id, &'a String);

Why we use pub struct AttributesKey and pub _reserved: Option<()> here ?

  • 1
    in order to reserve field for future type they use pub _reserved: Option<()>
    – go11li
    Commented May 28, 2023 at 1:37

1 Answer 1


This is why these two fields are used in the openbrush smart contract library:

  • pub struct AttributesKey: This struct is used to reserve space in the contract's storage for the attributes mapping. The attributes mapping is used to store a list of attributes for each token. The AttributesKey struct is empty, but it ensures that the storage space for the mapping will be reserved, even if the mapping is not used initially. This is important because the storage space for the mapping cannot be resized after the contract is deployed.
  • pub _reserved: Option<()>: This field is a reserved field that can be used by the contract's developer for future purposes. The field is not used by the contract itself, but it can be used by the developer to store additional data in the contract's storage. For example, the developer could use this field to store a timestamp of when the contract was deployed.

Your Answer

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

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