Crate pallet_template
source ·Expand description
§Template Pallet
A pallet with minimal functionality to help developers understand the essential components of writing a FRAME pallet. It is typically used in beginner tutorials or in Substrate template nodes as a starting point for creating a new pallet and not meant to be used in production.
§Overview
This template pallet contains basic examples of:
- declaring a storage item that stores a single
u32
value - declaring and using events
- declaring and using errors
- a dispatchable function that allows a user to set a new value to storage and emits an event upon success
- another dispatchable function that causes a custom error to be thrown
Each pallet section is annotated with an attribute using the #[pallet::...]
procedural macro.
This macro generates the necessary code for a pallet to be aggregated into a FRAME runtime.
Learn more about FRAME macros here.
§Pallet Sections
The pallet sections in this template are:
- A configuration trait that defines the types and parameters which the pallet depends on
(denoted by the
#[pallet::config]
attribute). See:Config
. - A means to store pallet-specific data (denoted by the
#[pallet::storage]
attribute). See:storage_types
. - A declaration of the events this pallet emits (denoted by the
#[pallet::event]
attribute). See:Event
. - A declaration of the errors that this pallet can throw (denoted by the
#[pallet::error]
attribute). See:Error
. - A set of dispatchable functions that define the pallet’s functionality (denoted by the
#[pallet::call]
attribute). See:dispatchables
.
Run cargo doc --package pallet-template --open
to view this pallet’s documentation.
Re-exports§
Modules§
- The
pallet
module in each FRAME pallet hosts the most important items needed to construct this pallet. - Autogenerated weights for pallet_template