rust开发环境搭建
rust切换版本
查看已经安装的版本和当前默认版本 rustup toolchain list
安装其他版本 rustup install nightly-2023-02-11
修改默认版本
rustup default stable:使用 stable 版本的 Rust 工具链作为默认版本。
rustup default beta:使用 beta 版本的 Rust 工具链作为默认版本。
rustup default nightly:使用 nightly 版本的 Rust 工具链作为默认版本。
切换到指定版本 stup default nightly-2023-02-11-aarch64-apple-darwin
substrate 运行hello word
rustc版本
(base) jiangxch@jiangxch substrate-node-template % rustup show
Default host: aarch64-apple-darwin
rustup home: /Users/jiangxch/.rustup
active toolchain
----------------
nightly-2023-02-11-aarch64-apple-darwin (default)
rustc 1.69.0-nightly (2773383a3 2023-02-10)
查看substrate编译的rustc版本 github.com/paritytech/…
git clone https://github.com/substrate-developer-hub/substrate-node-template.git
# 切换到分支=polkadot-v0.9.37
# 编译可执行文件
cargo build --release
# 如果编译报错xxx找不到 需要更新以来包
cargo update
# 运行区块链 单节点
./target/release/node-template --dev
# 清理节点连上状态
./target/release/node-template purge-chain --dev
开发poe模块
编写poe代码
poe模块代码见github.com/jiangxch/su… commit=40f919d8
配置poe打包金runtime
1.在runtime引入poe模块
pallet-poe = { version = "4.0.0-dev", default-features = false, path = "../pallets/poe" }
2.在编译标签配置poe,由于未使用try runtime和beanchmnark 不需要配置
"pallet-poe/std",
3.在runtime的lib.rs 配置poe模块的实现
impl pallet_poe::Config for Runtime {
type MaxClaimLength = ConstU32<512>;
type RuntimeEvent = RuntimeEvent;
}
4.poe引入到runtime的construct_runtime的枚举里面
PoeModule: pallet_poe
编译运行
通过浏览器与poe模块交互
-
进入前端页面=polkadot.js.org/apps/#/expl…
-
切换链到本地启动的链
- 进入chain state页面
4.查询某个cliaim是否存在
5.发起一笔交易
dev chain预设了一些账户