Configure Runtime Constants
Configure your pallet's types, events and errors
#[pallet::config] pub trait Config: frame_system::Config { type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; #[pallet::constant] // put the constant in metadata /// Maximum amount added per invocation. type MaxAddend: Get<u32>; /// Frequency with which the stored value is deleted. type ClearFrequency: Get<Self::BlockNumber>; }#[pallet::storage] #[pallet::getter(fn single_value)] pub(super) type SingleValue<T: Config> = StorageValue<_, u32, ValueQuery>;#[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event<T: Config> { /// The value has been added to. The parameters are /// (initial amount, amount added, final amount). Added(u32, u32, u32), /// The value has been cleared. The parameter is the value before clearing. Cleared(u32) }#[pallet::error] pub enum Error<T> { /// An operation would lead to an overflow. Overflow }
Create pallet methods and runtime constants
Examples
Resources
Last updated