referrerpolicy=no-referrer-when-downgrade

Trait pallet_example_kitchensink::pallet::Config

source ·
pub trait Config: Config {
    type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>;
    type WeightInfo: WeightInfo;
    type Currency: Inspect<Self::AccountId>;
    type InMetadata: Get<u32>;

    const FOO: u32;

    // Required method
    fn some_function() -> u32;
}
Expand description

Configuration trait of this pallet.

The main purpose of this trait is to act as an interface between this pallet and the runtime in which it is embedded in. A type, function, or constant in this trait is essentially left to be configured by the runtime that includes this pallet.

Consequently, a runtime that wants to include this pallet must implement this trait. The config trait of the pallet. You can basically do anything with the config trait that you can do with a normal rust trait: import items consisting of types, constants and functions.

A very common pattern is for a pallet to import implementations of traits such as [frame_support::traits::Currency], [frame_support::traits::fungibles::Inspect] and [frame_support::traits::Get]. These are all types that the pallet is delegating to the top level runtime to provide to it.

The FRAME-specific syntax are:

  • the use of #[pallet::constant]([frame_support::procedural]), which places a Get implementation in the metadata.
  • type RuntimeEvent, which is mandatory if your pallet has events. See TODO.
  • Needless to say, because Config is bounded by [frame_system::Config], you can use all the items from [frame_system::Config] as well, such as AccountId.
  • #[pallet::disable_frame_system_supertrait_check] would remove the need for frame_system::Config to exist, which you should almost never need.

Required Associated Types§

source

type RuntimeEvent: From<Event<Self>> + IsType<<Self as Config>::RuntimeEvent>

The overarching runtime event type.

source

type WeightInfo: WeightInfo

Type representing the weight of this pallet

source

type Currency: Inspect<Self::AccountId>

This is a normal Rust type, nothing specific to FRAME here.

source

type InMetadata: Get<u32>

This is a FRAME-specific item. It will be placed in the metadata of the pallet, and therefore can be queried by offchain applications.

Required Associated Constants§

source

const FOO: u32

And this

Required Methods§

source

fn some_function() -> u32

Similarly, let the runtime decide this.

Object Safety§

This trait is not object safe.

Implementors§