https://substrate.dev/docs/en/knowledgebase/getting-started/
https://substrate.dev/docs/en/tutorials/create-your-first-substrate-chain/
https://substrate.dev/docs/en/tutorials/start-a-private-network/

实践时的系统是:Linux Mint

本文的主题是创建一个只有一个节点的Substrate区块链。

一、Prerequisites

You will probably need to do some set-up to prepare your computer for Substrate development.

创建第一个Substrate Chain之前,要确保https://substrate.dev/docs/en/knowledgebase/getting-started/ 中讲的安装相关依赖的步骤完成了。如果这些步骤已经完成了,那么下面的 prepare a computer for Substrate development 这个步骤就不需要操作了。

prepare a computer for Substrate development

1. Build Dependencies

安装一些常用的基础的依赖工具。

因为是Linux Mint系统,所以按照 Ubuntu/Debian 这个类别安装依赖即可:

sudo apt update
# May prompt for location information
sudo apt install -y git clang curl libssl-dev llvm libudev-dev

2. Rust Developer Environment

安装Rust的开发环境,使用下面的自动脚本进行安装即可。

Automated getsubstrate.io Script

执行 curl https://getsubstrate.io -sSf | bash -s -- --fast

没有报错,就不需要手动安装了。

如果报错了,就进行下面的手动安装:

Manual Rust Configuration

This guide uses rustup to help manage the Rust toolchain. First install and configure rustup:

# Install
curl https://sh.rustup.rs -sSf | sh
# Configure
source ~/.cargo/env

Configure the Rust toolchain to default to the latest stable version, add nightly and the nightly wasm target:

rustup default stable
rustup update
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly

二、Compiling the Node Template

使用Git进行clone下载 Substrate Developer Hub Node Template的源码,这是构建Substrate的入口点。

1.Clone the Node Template (version v3.0.0+monthly-2021-05).

git clone -b v3.0.0+monthly-2021-05 --depth 1 https://github.com/substrate-developer-hub/substrate-node-template

2.Compile the Node Template

cd substrate-node-template
# NOTE: you should always use the `--release` flag
cargo build --release
# ^^ this will take a while!

等待编译,编译时间的长短由机器的硬件决定。

编译完成的log输出如下:

...Compiling sc-chain-spec v3.0.0 (https://github.com/paritytech/substrate.git?tag=monthly-2021-05#70ef0afc)Compiling rocksdb v0.16.0Compiling kvdb-rocksdb v0.11.1Compiling sc-client-db v0.9.0 (https://github.com/paritytech/substrate.git?tag=monthly-2021-05#70ef0afc)Compiling sc-service v0.9.0 (https://github.com/paritytech/substrate.git?tag=monthly-2021-05#70ef0afc)Compiling sc-cli v0.9.0 (https://github.com/paritytech/substrate.git?tag=monthly-2021-05#70ef0afc)Compiling frame-benchmarking-cli v3.0.0 (https://github.com/paritytech/substrate.git?tag=monthly-2021-05#70ef0afc)Finished release [optimized] target(s) in 6m 41s

三、Install the Front-End Template

本步骤的教程使用ReactJS作为前端模板,允许您与基于Substrate的区块链节点进行交互,您应该在上一步中开始编译节点。将来您可以使用这个相同的前端模板为自己的项目创建ui。

要使用前端模板,需要Yarn,它本身需要Node.js。如果没有这些工具,则必须按照以下说明进行安装:
Install Node.js
Install Yarn

现在可以使用这些命令设置前端模板:

# Clone the frontend template from github
git clone -b v3.0.0+monthly-2021-05 --depth 1 https://github.com/substrate-developer-hub/substrate-front-end-template# Install the dependencies
cd substrate-front-end-template
yarn install

安装完成的log输出如下:

~/SubstratePrivateNetwork/substrate-front-end-template$ yarn install
➤ YN0065: Yarn will periodically gather anonymous telemetry: https://yarnpkg.com/advanced/telemetry
➤ YN0065: Run yarn config set --home enableTelemetry 0 to disable➤ YN0000: ┌ Resolution step
➤ YN0002: │ react-dev-utils@npm:11.0.4 doesn't provide typescript (p79ddf), requested by fork-ts-checker-webpack-plugin
➤ YN0002: │ react-dev-utils@npm:11.0.4 doesn't provide webpack (p2af19), requested by fork-ts-checker-webpack-plugin
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0013: │ yargs-parser@npm:13.1.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yargs-parser@npm:18.1.3 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yargs@npm:13.3.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yargs@npm:15.4.1 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yocto-queue@npm:0.1.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed in 23s 848ms
➤ YN0000: ┌ Link step
➤ YN0062: │ fsevents@patch:fsevents@npm%3A2.3.2#builtin<compat/fsevents>::version=2.3.2&hash=11e9ea The platform linux is incompatible with this module, link skipped.
➤ YN0062: │ fsevents@patch:fsevents@npm%3A1.2.13#builtin<compat/fsevents>::version=1.2.13&hash=11e9ea The platform linux is incompatible with this module, link skipped.
➤ YN0007: │ core-js@npm:3.13.0 must be built because it never did before or the last one failed
➤ YN0007: │ core-js@npm:2.6.12 must be built because it never did before or the last one failed
➤ YN0007: │ bufferutil@npm:4.0.3 must be built because it never did before or the last one failed
➤ YN0007: │ utf-8-validate@npm:5.0.5 must be built because it never did before or the last one failed
➤ YN0007: │ node-hid@npm:2.1.1 must be built because it never did before or the last one failed
➤ YN0007: │ usb-detection@npm:4.10.0 must be built because it never did before or the last one failed
➤ YN0007: │ tiny-secp256k1@npm:1.1.6 must be built because it never did before or the last one failed
➤ YN0007: │ core-js-pure@npm:3.13.0 must be built because it never did before or the last one failed
➤ YN0007: │ ejs@npm:2.7.4 must be built because it never did before or the last one failed
➤ YN0000: └ Completed in 1m 5s
➤ YN0000: Done with warnings in 1m 30s

四、Background Information

五、Interacting with Your Node

现在,您的节点已经完成编译,让我们向您展示如何开箱即用。

Starting Your Node

运行以下命令以启动您的节点(执行命令时是在substrate-node-template目录下):

# Run a temporary node in development mode
./target/release/node-template --dev --tmp

Note the flags:

  • –dev this sets up a developer node chain specification
  • –tmp this saves all active data for the node (keys, blockchain database, networking info, …) and is deleted as soon as you properly terminate your node (using ctrl+c). So every time you start with this command, you will have a clean state to work from. If the node is killed, /tmp is cleaned automatically on the restart of your computer for linux based OSs, and these files can manually be removed if needed.

使用此命令,如果您的节点运行成功,您应该会看到如下内容:

2021-03-16 10:56:51  Running in --dev mode, RPC CORS has been disabled.
2021-03-16 10:56:51  Substrate Node
2021-03-16 10:56:51  ✌️  version 3.0.0-8370ddd-x86_64-linux-gnu
2021-03-16 10:56:51  ❤️  by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021
2021-03-16 10:56:51  												

Substrate Tutorials:Create Your First Substrate Chain (single-node)相关推荐

  1. Substrate Tutorials:Start a Private Network (multi-node)

    https://substrate.dev/docs/en/tutorials/start-a-private-network/ Substrate Start a Private Network 搭 ...

  2. 翻译:CREATE DATABASE语句

    本文为mariadb官方手册:CREATE DATABASE的译文. 原文:https://mariadb.com/kb/en/create-database/ 我提交到MariaDB官方手册的译文: ...

  3. 12c:CREATE DATABASE——DBCA

    界面1:Welcome     选择Create a Database,点击next 界面2:Step 2 of 14: Creation Mode     选择Advanced configurat ...

  4. oracle 怎么创建类型,ORACLE—002:Create之创建类型

    --积累工作中用到的SQL ORACLE中也是有类型的,可作为存储过程,函数等的输入输入出. 下面看下创建. 用法 CREATE OR REPLACE TYPE 类型名称 AS OBJECT ( 字段 ...

  5. Druid连接池链接mysql错误提示:create connection SQLException, url: jdbc:mysql://127.0.0.1:3306/bank, errorCode

    错误提示:create connection SQLException, url: jdbc:mysql://127.0.0.1:3306/bank, errorCode 0, state 01S00 ...

  6. mysql表的基础操作: Create,,Retrieve,Update,Delete(大量示例)

    以下是阿鲤数据库基础查询的学习总结以及大量的练习,如果大家可以将此篇博客的练习做完,可以有校的加深大家对数据库的使用:如果你还不了解数据库,请浏览这篇博客数据库基础 一:create 二:retrie ...

  7. Pragmatic Scala:Create Expressive, Concise, and Scalable Applications (读书笔记)

    Pragmatic Scala:Create Expressive, Concise, and Scalable Applications 目录 1 From Java to Scala 2 Obje ...

  8. 关于MySQL : CREATE TABLE if not exists xxx/ALTER TABLE xxx ADD COLUMN IF NOT EXISTS xxx语法使用注意

    背景 在测试程序时,对于你新建的表,并且额外插入了其他新的列字段.当你再次插入时,报错,表名或者列名重复. 导致的结果 导致的结果就是你的程序运行不下去,因为在你周期调度,或者再次调度时,逻辑上需要再 ...

  9. zabbix集成onealert验证报错:create media type failed! error message

    zabbix集成onealert验证报错:create media type failed! error message 一.报错详细信息 [root@host-10-10-6-20 bin]# ba ...

最新文章

  1. 如何挖掘系统的业务价值
  2. 建立注册DLL和反注册DLL文件的快捷方式
  3. 最长公共子序列(LCS问题)
  4. Exchange2010外部传输域的使用方法
  5. c语言添加变量到数据库+a+ +b+ 的方法,《C程序设计基础》模拟考试题(含答案)...
  6. CCF202009-1 称检测点查询
  7. CSDN 日报第 1 期:蚂蚁集团将向机构投资者退款;Pyston v2 发布 比 Python 快 20%
  8. 关于C# 模仿千千静听 磁铁窗体 的个人的一个思路
  9. 【BZOJ1452】【JSOI2009】count
  10. 利用UrlRewrite,asp.net动态生成htm页面
  11. 信号处理第一式——离散信号序列的基本运算及MATLAB实现
  12. arduino 土壤温湿度传感器_arduino测量土壤湿度自动浇水提醒 - 全文
  13. 【新知实验室】腾讯云TRTC接入测试以及状态同步功能重点验证
  14. 汽车高级驾驶辅助系统ADAS全盘点
  15. 综述!推荐系统中的自监督学习
  16. 多目标灰太狼算法求解环境经济调度问题(IEEE30)(Matlab实现)
  17. Verilog除法器(32位无符号+带符号)
  18. 青少年沉迷游戏得鱼教育老师告诉家长如何处理
  19. NYOJ-110-剑客决斗
  20. js内置对象中的String

热门文章

  1. 常用的设计模式(一)—工厂与抽象工厂模式
  2. django的setting.py文件配置
  3. python怎么自动抢红包软件_【一点资讯】超强大!教你用Python自动抢红包,再也不会错过任何一分钱...
  4. iOS微信自动抢红包实现(非越狱)
  5. 轻松集齐五福,还有花花,原来你要扫的福字都在这里!
  6. 智慧产业园区标准体系总体框架
  7. 软件中的“黑马”,你知道的有哪些?
  8. 如何借势视频号,加速内容变现?
  9. 我的2020,一个初创者的自述与思考
  10. Android Studio升级后 出现在No subject alternative DNS name matching services.gradle.org found.