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 Polkadot SDK template 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 block-number
- 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.
To get started with pallet development, consider using this tutorial:
And reading the main documentation of the frame crate:
And looking at the frame kitchen-sink
pallet, a showcase of all pallet macros.
§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§
pub use pallet::*;