-
Make sure you already have Rust build environment setup on your computer:
https://docs.substrate.io/install/
If you don't... probably best to just watch along.
-
Clone the
substrate-node-template
.
git clone https://github.com/substrate-developer-hub/substrate-node-template
-
Replace the contents of
substrate-node-template/pallets/template/src/lib.rs
with the Empty Pallet Template. -
Compile your project. Don't worry about warnings :)
cargo build -p pallet-template
If you got this far, then you are ready to move forward!
#![cfg_attr(not(feature = "std"), no_std)]
pub use pallet::*;
#[frame_support::pallet]
pub mod pallet {
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
// The struct on which we build all of our Pallet logic.
#[pallet::pallet]
pub struct Pallet<T>(_);
/* Placeholder for defining custom types. */
/* Placeholder for defining custom storage items. */
// Your Pallet's configuration trait, representing custom external types and interfaces.
#[pallet::config]
pub trait Config: frame_system::Config {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
}
// Your Pallet's events.
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {}
// Your Pallet's error messages.
#[pallet::error]
pub enum Error<T> {}
// Your Pallet's callable functions.
#[pallet::call]
impl<T: Config> Pallet<T> {}
// Your Pallet's internal functions.
impl<T: Config> Pallet<T> {}
}