1. 在pallets目录下创建新pallet的目录
添加Cargo.toml,可以复制template下的文件来修改,
修改toml文件中的描述,一般改name和description其它不用动
创建子目录src并创建文件lib.rs做为pallet的源码文件
2. 修改runtime下的Cargo.toml
首先添加本地依赖
然后修改std列表,添加新的pallet
[features]
default = ['std']
runtime-benchmarks = [
......
]
std = [
'codec/std',
'scale-info/std',
'frame-executive/std',
......
'pallet-storage-provider/std',
]
3. 修改runtime下的src\lib.rs
添加runtime对pallet的实现
修改construct_runtime列表
construct_runtime!(
pub enum Runtime where
Block = Block,
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
System: frame_system,
......
// Include the custom logic from the pallet-template in the runtime.
TemplateModule: pallet_template,
StorageModule : pallet_storage_provider,
}
);