0
decl_storage! {
    trait Store for Module<T: Trait> as KittyStorage {
        Kitties get(kitty): map T::Hash => Kitty<T::Hash, T::Balance>;
  1. What is this for use?

  2. What is Store ? is this a trait?

  3. then Module is what?

  4. decl_storage! macro is for what purpose? create multiple storage object suites?

  5. what is <T: Trait> as KittyStorage ? you give name Module as KittyStorage?

Kitties get(kitty): map T::Hash => Kitty<T::Hash, T::Balance>;

Kitties object has get method, attribute is kitty, then map iterate T::Hash , return Kitty object which has T::Hash and T::Balance trait.

is it right...?

2 Answers 2

1

Well , I really dont think there is a need for you to keep hustling FRAME V1 syntax. Because The declarative macros used there dont follow rust syntax. So I think you should focus on V2. And It will be hard for u to get further help in your journey if you keep using V1 as now V2 is used officially and it is easy to debug

1
1

The decl_*! macros were deprecated specifically for the confusion they cause, and as illustrated in this question.

Because they define their own syntax, which is not Rust, you basically need to understand how the macro parses the code block to understand what is going on.

I do not suggest you keep moving forward with FRAME V1, and instead suggest you use the FRAME V2 macros.

Anyway, to answer your question:

  1. trait Store for Module is trying to look like the impl Trait for Struct syntax, and it is doing the same thing. There is a trait Store which is being implemented for Module.

  2. Yes it is a trait which is generated on the fly for each pallet. It lists the storage items available in the pallet.

  3. Module is a struct which represents the whole pallet. In all the latest pallets, this is renamed to Pallet.

  4. decl_storage! is used to define storage items which can be used in your runtime logic, and store data on the blockchain. It provides access between your pallet code, and the Substrate database.

  5. <T: Trait> is part of Module<T: Trait>, and it is a generic parameter. KittyStorage is the storage prefix name used when generating storage for the pallet.

  6. is not a question.

1
  • Thank you Shawn. your tutorial is awesome May 15 at 2:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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