Expand description
The pallet module in each FRAME pallet hosts the most important items needed
to construct this pallet.
The main components of this pallet are:
Pallet, which implements all of the dispatchable extrinsics of the pallet, among other public functions.- The subset of the functions that are dispatchable can be identified either in the
dispatchablesmodule or in theCallenum.
- The subset of the functions that are dispatchable can be identified either in the
storage_types, which contains the list of all types that are representing a storage item. Otherwise, all storage items are listed among Type Definitions.Config, which contains the configuration trait of this pallet.EventandError, which are listed among the Enums.
Modules§
- dispatchables
- Auto-generated docs-only module listing all defined dispatchables for this pallet.
- storage_
types - Auto-generated docs-only module listing all (public and private) defined storage types for this pallet.
Structs§
- Default
ForFoo - Genesis
Config - The genesis config type. This allows the pallet to define how it should initialized upon genesis.
- Pallet
- The pallet struct. There’s nothing special to FRAME about this; it can implement functions in an impl blocks, traits and so on.
Enums§
- Call
- The call declaration. This states the entry points that we handle. The macro takes care of the marshalling of arguments and dispatch.
- Error
- The error enum. Must always be generic over
<T>, which is expanded to<T: Config>. - Event
- The event type. This exactly like a normal Rust enum.
- Hold
Reason - Allows you to define an enum on the pallet which will then instruct
construct_runtimeto amalgamate all similarly-named enums from other pallets into an aggregate enum.
Traits§
- Config
- Configuration trait of this pallet.
Functions§
Type Aliases§
- Alternative
Syntax - In all of these examples, we chose a syntax where the storage item is defined using the
explicit generic syntax (
X = Y). Alternatively: - Alternative
Syntax2 - Lastly, all storage items, as you saw, had to be generic over
T. If they want to use an item fromConfig,<T: Config>should be used. - Bar
- A storage map. This creates a mapping from keys of type
u32to values of typeu32. - Foo
- A storage value. We mark this as unbounded, alter its prefix, and define a custom storage getter for it.
- FooWith
Default - Storage type is [
StorageValue] with value typeu32. - Module
Deprecated - Type alias to
Pallet, to be used byconstruct_runtime. - Origin
- Allows you to define some origin for the pallet.
- Quux
- Same as
StorageDoubleMap, but with arbitrary number of keys. - Qux
- Conceptually same as
StorageMap<>where the key is a tuple of(u32, u32). On top, it provides some functions to iterate or remove items based on only the first key.