I'm fiddling with substrate's #[pallet::generate_store(pub(super) trait Store)]

Documentation says

Generates the Store trait if the attribute is provided, which contains an associated type for each storage item. It takes the form of a more explicit Rust struct module and can be written as pub struct Pallet(_);, with the appropriate PhantomData replacing _ to make it generic.

Here is my kittens pallet. Even if I remove the macro mentioned above, node works fine as expected.

I tried applying cargo expand with both cases is that I found out the following differences. A Store trait and it's implemented for Pallet Struct.
enter image description here

But in both the cases my functionality is not impacted at all. It mutates chain state and queries the state as expected.


Why should we use this #[pallet::generate_store(pub(super) trait Store)]? What's the point?

  • How do you access the Storage items otherwise? This link has slightly more info: docs.substrate.io/rustdocs/latest/frame_support/…
    – Georges
    Mar 28, 2022 at 20:01
  • Can you elaborate on this @Georges? I didn't get your point here by access the Storage item, do you mean accessing the state of storage?
    – Arjun
    Mar 29, 2022 at 0:04
  • Have you built your runtime using cargo build and have ran the chain? What check did you do to verify that it "mutates chain state and queries the state as expected" ? Mar 29, 2022 at 10:06
  • Ran the chain after building with cargo build. And checked with polkadot.js chainstate and extrinsics. Worked perfectly identcal.
    – Arjun
    Mar 29, 2022 at 15:43

3 Answers 3


I believe this is an artifact from the the old design for how we collected all the different storage items in the decl_storage! macro in FRAME v1.

Here is an example definition:

crate::decl_storage! {
    trait Store for Module<T: Config> as Runtime {
        Value get(fn value) config(): (u64, u64);
        NumberMap: map hasher(identity) u32 => u64;
        DoubleMap: double_map hasher(identity) u32, hasher(identity) u32 => u64;

As you can see, the old macro simply wrapped an entire trait Store, and generated all the storage items using this.

When redesigning FRAME storage for FRAME v2, an individual type pattern was used:

pub type Value<T> = StorageValue<_, u32>;

pub type Map<T> = StorageMap<_, Blake2_128Concat, u8, u16>;

pub type DoubleMap<T> =
    StorageDoubleMap<_, Blake2_128Concat, u8, Twox64Concat, u16, u32>;

To maintain backwards compatibility, this extra generate_store attribute was created. It should not affect you as a pallet developer if you use it or not.


The Store trait, as you see, just creates some aliases, and is completely optional.

For example, with this trait, you can access all of the storage items regardless of being pub or not as associated type Pallet. Although, in FRAME v2 all storage items have to be pub(crate) at the minimum, and I think the Store trait only exists in FRAME v2 for backwards compatibility and will likely be removed in further versions.

  • Can I say Store trait is deprecated after FRAME V2? By the way just out of curiosity, can you tell what was it's usecase under what circumstances a developer need those aliases?
    – Arjun
    Mar 29, 2022 at 15:46
  • I am using FRAME v2 and in v2 there is no error when declaring the Storage with private visibility. But also Id didn't found any difference b/w pub(super) and private for the storage because in both case I am able to access it from PolkadotJs Explorer
    – Asmita
    May 26, 2022 at 15:55
I tried to declare storage as private as below

#[pallet::generate_store(trait Store)]
pub struct Pallet<T>(_);

#[pallet::getter( fn running_status)]
type SystemRunnig<T> = StorageValue<_, bool, ValueQuery>;

It compiles fine and even I am able to access and see the status of the SystemRunnig from polkadotJs explorer.

So here what is meant via declaring it private. can you explain

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.