Import a Pallet
This guide demonstrates how to quickly integrate both local and external pallets in a runtime. For more detailed step-by-step instructions, see Add a pallet to the runtime.
This guide illustrates:
How to include a custom local pallet that implements an event and a call for the runtime.
How to include an external pallet from
Crates.io
in the runtime.
Create a local pallet
Create a local pallet called
pallet_something
.Import this pallet by adding the following to
/runtime/src/lib.rs
:Configure your pallet's runtime implementation. Assume the local pallet only has the
Event
andCall
types exposed to the runtime. Add the following to/runtime/src/lib.rs
:Declare your pallet for the
construct_runtime
macro:Update
/runtime/Cargo.toml
In
/runtime/Cargo.toml
, include your pallet as a local dependency instd
and addruntime-benchmarks
. For example:
Import an external pallet
To add an external pallet, you use a similar method to the one you used with the local pallet, but you must include all of the types your pallet exposes. You must also include the relevant parameter types and constants. For examples of how to declare parameters and constants, see pallet_timestamp
.
The following is an example of how you would add an external pallet to the /runtime/Cargo.toml
dependencies if the pallet is hosted on crates.parity.io:
Examples
Related material
Last updated