substrate学习笔记1:Substrate初体验

substrate是用Rust实现的区块链框架,可以说是区块链界的第一个轮子。从本节开始,我们就开始substrate的学习,将结合我们之前学习的rust知识,进一步掌握substrate知识。

学习内容

本节将进行:

  • 搭建substrate的开发环境;
  • 使用template运行基于substrate的区块链;
  • 使用substrate的前端模板和我们搭建的区块链进行交互。

搭建开发环境

  • 安装依赖

    curl https://getsubstrate.io -sSf | bash -s -- --fast
  • 克隆Substrate Node Template

    git clone -b v3.0.0 --depth 1 https://github.com/substrate-developer-hub/substrate-node-template
  • 初始化WebAssembly构建环境

    source ~/.cargo/env
    rustup default stable
    rustup update
    rustup update nightly
    rustup target add wasm32-unknown-unknown --toolchain nightly
  • 编译substrate节点模板

    cd substrate-node-template/
    cargo build --release
  • 安装front-end模板

在安装之前需要先安装Node.js和Yarn。安装front-end模板命令如下:

git clone -b v3.0.0 --depth 1 https://github.com/substrate-developer-hub/substrate-front-end-template

cd substrate-front-end-template
yarn install

与节点交互

  • 启动节点
./target/release/node-template --dev --tmp
  • 启动前端
yarn start
  • 交互
  • 前端界面启动后,默认会有一些账户,其中前几个账户也默认有一些币,我们可以用transfer功能在账户间做转账测试。

注意:转账的金额必须大于1000000000000,否则感受不到账户的变化。

遇到问题记录

  • 问题一

现象:

error:failed to run custom build command

解决方式:

rustup default nightly
  • 问题二

现象:

error: failed to run custom build command for `node-template-runtime v2.0.0 (/home/andy/source/learn_substrate/first/substrate-node-template/runtime)`

Caused by:
  process didn't exit successfully: `/home/andy/source/learn_substrate/first/substrate-node-template/target/release/build/node-template-runtime-9741a79fa92df57d/build-script-build` (exit status: 1)

解决方式:

cargo install cargo-generate --locked cargo --force
本作品采用《CC 协议》,转载必须注明作者和本文链接
令狐一冲
讨论数量: 1

环境配置好了之后..cargo build 一开始提示gcc.exe丢失..从网上下载了一个msys2解决了.. 现在提示这个问题不知道怎么处理..往前辈可以给点建议

file

error: failed to run custom build command for libp2p-core v0.37.0

Caused by: process didn't exit successfully: /home/centos/substrate-node-template/target/debug/build/libp2p-core-47bd58583c2f207e/build-script-build (exit status: 101) --- stderr thread 'main' panicked at 'called Result::unwrap() on an Err value: Custom { kind: Other, error: "protoc failed: envelope.proto:1:10: Unrecognized syntax identifier "proto3". This parser only recognizes "proto2".\n" }', /home/centos/.cargo/registry/src/github.com-1ecc6299db9ec823/libp2p-core-0.37.0/build.rs:30:6 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
文章
255
粉丝
120
喜欢
308
收藏
128
排名:335
访问:2.8 万
私信
所有博文
社区赞助商