substrate区块链(Add a pallet to the runtime)

该文详细介绍了如何在Substrateruntime中集成pallet-nicks模块,包括在Cargo.toml中添加依赖,配置std,实现ConfigforRuntime,设置各种参数如ReservationFee和forceorigin,并提到启动前端进行相关操作。
摘要由CSDN通过智能技术生成

1、在runtime/Cargo.toml中添加依赖

pallet-nicks = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.42" }

2、在runtime/Cargo.toml配置std

"pallet-nicks/std",

3、在runtime/src/lib.rs中添加Nicks相关信息 

impl pallet_nicks::Config for Runtime {
// The Balances pallet implements the ReservableCurrency trait.
// `Balances` is defined in `construct_runtime!` macro.
type Currency = Balances;

// Set ReservationFee to a value.
type ReservationFee = ConstU128<100>;

// No action is taken when deposits are forfeited.
type Slashed = ();

// Configure the FRAME System Root origin as the Nick pallet admin.
// https://paritytech.github.io/substrate/master/frame_system/enum.RawOrigin.html#variant.Root
type ForceOrigin = frame_system::EnsureRoot<AccountId>;

// Set MinLength of nick name to a desired value.
type MinLength = ConstU32<8>;

// Set MaxLength of nick name to a desired value.
type MaxLength = ConstU32<32>;

// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
}

4、启动前端并作相关操作,参照英文文档

Add a pallet to the runtime | Substrate_ Docs

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值