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.0
Compiling kvdb-rocksdb v0.11.1
Compiling 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 📋 Chain specification: Development
2021-03-16 10:56:51 🏷 Node name: few-size-5380
2021-03-16 10:56:51 👤 Role: AUTHORITY
2021-03-16 10:56:51 💾 Database: RocksDb at /tmp/substrateP1jD7H/chains/dev/db
2021-03-16 10:56:51 ⛓ Native runtime: node-template-100 (node-template-1.tx1.au1)
2021-03-16 10:56:51 🔨 Initializing Genesis block/state (state: 0x17df…04a0, header-hash: 0xc43b…ed16)
2021-03-16 10:56:51 👴 Loading GRANDPA authority set from genesis on what appears to be first startup.
2021-03-16 10:56:51 ⏱ Loaded block-time = 6000 milliseconds from genesis on first-launch
2021-03-16 10:56:51 Using default protocol ID "sup" because none is configured in the chain specs
2021-03-16 10:56:51 🏷 Local node identity is: 12D3KooWQdU84EJCqDr4aqfhb7dxXU2fzd6i2Rn1XdNtsiM5jvEC
2021-03-16 10:56:51 📦 Highest known block at #0
2021-03-16 10:56:51 〽️ Prometheus server started at 127.0.0.1:9615
2021-03-16 10:56:51 Listening for new connections on 127.0.0.1:9944.
2021-03-16 10:56:54 🙌 Starting consensus session on top of parent 0xc43b4514877d7dcfff2459cdfe609a96cf8e9b9723589635d7215de6bf00ed16
2021-03-16 10:56:54 🎁 Prepared block for proposing at 1 [hash: 0x255bcf44df92dd4ccaca15d92d4a3db9d276e42843e21ab0cc840e207b2649d6; parent_hash: 0xc43b…ed16; extrinsics (1): [0x02bf…2cbd]]
2021-03-16 10:56:54 🔖 Pre-sealed block for proposal at 1. Hash now 0x9c14d9caccc37f8142fc348d184fb4bd8a8bc217a8979493d7f46d4220775616, previously 0x255bcf44df92dd4ccaca15d92d4a3db9d276e42843e21ab0cc840e207b2649d6.
2021-03-16 10:56:54 ✨ Imported #1 (0x9c14…5616)
2021-03-16 10:56:54 🙌 Starting consensus session on top of parent 0x9c14d9caccc37f8142fc348d184fb4bd8a8bc217a8979493d7f46d4220775616
2021-03-16 10:56:54 🎁 Prepared block for proposing at 2 [hash: 0x6cd4bd9d2a531750c10610bdaa5af0075745b6612ffa3623c14d699250b4e732; parent_hash: 0x9c14…5616; extrinsics (1): [0x3cc8…b8d9]]
2021-03-16 10:56:54 🔖 Pre-sealed block for proposal at 2. Hash now 0x05bd3317b51d717163dfa8847369d7f697c6180868c29f02d0b7ff79c5bbde3f, previously 0x6cd4bd9d2a531750c10610bdaa5af0075745b6612ffa3623c14d699250b4e732.
2021-03-16 10:56:54 ✨ Imported #2 (0x05bd…de3f)
2021-03-16 10:56:56 💤 Idle (0 peers), best: #2 (0x05bd…de3f), finalized #0 (0xc43b…ed16), ⬇ 0 ⬆ 0
2021-03-16 10:57:00 🙌 Starting consensus session on top of parent 0x05bd3317b51d717163dfa8847369d7f697c6180868c29f02d0b7ff79c5bbde3f
2021-03-16 10:57:00 🎁 Prepared block for proposing at 3 [hash: 0xa6990964cf4f184edc08acd61c3c01ac8975abbba6d42f4eec3f9658097aec04; parent_hash: 0x05bd…de3f; extrinsics (1): [0xd6ed…86a5]]
2021-03-16 10:57:00 🔖 Pre-sealed block for proposal at 3. Hash now 0xbe07e322ca525e580a3703637db191c6df091b0242a411b88fa0c43ef0ac31f8, previously 0xa6990964cf4f184edc08acd61c3c01ac8975abbba6d42f4eec3f9658097aec04.
2021-03-16 10:57:00 ✨ Imported #3 (0xbe07…31f8)
2021-03-16 10:57:01 💤 Idle (0 peers), best: #3 (0xbe07…31f8), finalized #1 (0x9c14…5616), ⬇ 0 ⬆ 0
如果finalized:
后面的数字在增加,则您的区块链正在生成新区块并就它们描述的状态达成共识!
关于上面示例输出的一些注意事项:
💾 Database: RocksDb at /tmp/substrateP1jD7H/chains/dev/db
:链上数据的写入位置🏷 Local node identity is: 12D3KooWQdU84EJCqDr4aqfhb7dxXU2fzd6i2Rn1XdNtsiM5jvEC
:如果你打算直接连接到其他节点所需要的节点ID(更多相关信息在 私有网络教程 中)
虽然现在不是很重要,但请务必阅读您节点的所有启动日志,因为它们有助于在您后续学习和通过这些第一个基本教程时提醒您关键配置信息。
实际操作时的log如下:
~/SubstratePrivateNetwork/substrate-node-template$ ./target/release/node-template --dev --tmp
2021-06-28 19:16:20 Running in --dev mode, RPC CORS has been disabled.
2021-06-28 19:16:20 Substrate Node
2021-06-28 19:16:20 ✌️ version 3.0.0-12d56a7-x86_64-linux-gnu
2021-06-28 19:16:20 ❤️ by Substrate DevHub <https://github.com/substrate-developer-hub>, 2017-2021
2021-06-28 19:16:20 📋 Chain specification: Development
2021-06-28 19:16:20 🏷 Node name: nebulous-earth-9275
2021-06-28 19:16:20 👤 Role: AUTHORITY
2021-06-28 19:16:20 💾 Database: RocksDb at /tmp/substrateAw2949/chains/dev/db
2021-06-28 19:16:20 ⛓ Native runtime: node-template-100 (node-template-1.tx1.au1)
2021-06-28 19:16:20 🔨 Initializing Genesis block/state (state: 0xa78e…5dc2, header-hash: 0x2c28…5e62)
2021-06-28 19:16:20 👴 Loading GRANDPA authority set from genesis on what appears to be first startup.
2021-06-28 19:16:20 ⏱ Loaded block-time = 6s from genesis on first-launch
2021-06-28 19:16:20 Using default protocol ID "sup" because none is configured in the chain specs
2021-06-28 19:16:20 🏷 Local node identity is: 12D3KooWQZH5AxqxDbRxnSJAMmZLtmncT2FHvkwo7U7fCj349Lhp
2021-06-28 19:16:20 📦 Highest known block at #0
2021-06-28 19:16:20 〽️ Prometheus server started at 127.0.0.1:9615
2021-06-28 19:16:20 Listening for new connections on 127.0.0.1:9944.
2021-06-28 19:16:24 🙌 Starting consensus session on top of parent 0x2c28565e1f5a2018e93744cbd39b7a60ada4a3fc885d8260319ed556d9e15e62
2021-06-28 19:16:24 🎁 Prepared block for proposing at 1 [hash: 0xa3bb5dbff5cb5d8bc174cabc8cb123732c43f432d324342698c8db59aeb248ba; parent_hash: 0x2c28…5e62; extrinsics (1): [0x3b96…c58a]]
2021-06-28 19:16:24 🔖 Pre-sealed block for proposal at 1. Hash now 0x93333c267f3582d0392d1f8e948e791da0a24edc897bd82ed2f1ebfdf78927b3, previously 0xa3bb5dbff5cb5d8bc174cabc8cb123732c43f432d324342698c8db59aeb248ba.
2021-06-28 19:16:24 ✨ Imported #1 (0x9333…27b3)
2021-06-28 19:16:25 💤 Idle (0 peers), best: #1 (0x9333…27b3), finalized #0 (0x2c28…5e62), ⬇ 0 ⬆ 0
2021-06-28 19:16:30 🙌 Starting consensus session on top of parent 0x93333c267f3582d0392d1f8e948e791da0a24edc897bd82ed2f1ebfdf78927b3
2021-06-28 19:16:30 🎁 Prepared block for proposing at 2 [hash: 0x3b3ec277af362cc453dd972d2681caa1ad20496fb6625bd2f116f39733c218bd; parent_hash: 0x9333…27b3; extrinsics (1): [0xd407…9437]]
2021-06-28 19:16:30 🔖 Pre-sealed block for proposal at 2. Hash now 0xd436c61eb3feff5fd755dd0dcaa767e4e4b207065171b513bbedda5e0b0e701d, previously 0x3b3ec277af362cc453dd972d2681caa1ad20496fb6625bd2f116f39733c218bd.
2021-06-28 19:16:30 ✨ Imported #2 (0xd436…701d)
2021-06-28 19:16:30 💤 Idle (0 peers), best: #2 (0xd436…701d), finalized #0 (0x2c28…5e62), ⬇ 0 ⬆ 0
2021-06-28 19:16:35 💤 Idle (0 peers), best: #2 (0xd436…701d), finalized #0 (0x2c28…5e62), ⬇ 0 ⬆ 0
2021-06-28 19:16:36 🙌 Starting consensus session on top of parent 0xd436c61eb3feff5fd755dd0dcaa767e4e4b207065171b513bbedda5e0b0e701d
2021-06-28 19:16:36 🎁 Prepared block for proposing at 3 [hash: 0x9c794c680c76662b57e1f8a8519e026b52a7cc1cf2b7bef818859c4fe128172f; parent_hash: 0xd436…701d; extrinsics (1): [0x1fd3…98df]]
2021-06-28 19:16:36 🔖 Pre-sealed block for proposal at 3. Hash now 0x15a82b1c3312726a7d8b721793fb6234144aa335e32a57128b5b5e33f801922e, previously 0x9c794c680c76662b57e1f8a8519e026b52a7cc1cf2b7bef818859c4fe128172f.
2021-06-28 19:16:36 ✨ Imported #3 (0x15a8…922e)
...
2021-06-28 19:20:48 ✨ Imported #45 (0x91ae…4dac)
2021-06-28 19:20:50 💤 Idle (0 peers), best: #45 (0x91ae…4dac), finalized #43 (0xf120…504b), ⬇ 0 ⬆ 0
2021-06-28 19:20:54 🙌 Starting consensus session on top of parent 0x91ae4852b3d5599b40e3fe4045af7c435478bbe8f279c455b6b98164616d4dac
2021-06-28 19:20:54 🎁 Prepared block for proposing at 46 [hash: 0x8bc673e87f3be7ef62a5a9e7fc857d7d68810a2c55025b74658de33f046b49f1; parent_hash: 0x91ae…4dac; extrinsics (1): [0x9365…e839]]
2021-06-28 19:20:54 🔖 Pre-sealed block for proposal at 46. Hash now 0x2de22b08a082303c2e12e2ee468dba7fa9181e5fcd678e0eee1fe314242c646f, previously 0x8bc673e87f3be7ef62a5a9e7fc857d7d68810a2c55025b74658de33f046b49f1.
2021-06-28 19:20:54 ✨ Imported #46 (0x2de2…646f)
2021-06-28 19:20:55 💤 Idle (0 peers), best: #46 (0x2de2…646f), finalized #44 (0x16d0…cca3), ⬇ 0 ⬆ 0
2021-06-28 19:21:00 🙌 Starting consensus session on top of parent 0x2de22b08a082303c2e12e2ee468dba7fa9181e5fcd678e0eee1fe314242c646f
2021-06-28 19:21:00 🎁 Prepared block for proposing at 47 [hash: 0x0df19a2b20f207b6c67def3fdcb95aebe4f03670e6b58088f2a4f4ebf0814fe7; parent_hash: 0x2de2…646f; extrinsics (1): [0x294e…c0b3]]
2021-06-28 19:21:00 🔖 Pre-sealed block for proposal at 47. Hash now 0xe84b108a4c0f8367350d3d94c4958542bc8f7c76f66834f23cb4092aef761339, previously 0x0df19a2b20f207b6c67def3fdcb95aebe4f03670e6b58088f2a4f4ebf0814fe7.
2021-06-28 19:21:00 ✨ Imported #47 (0xe84b…1339)
2021-06-28 19:21:00 💤 Idle (0 peers), best: #47 (0xe84b…1339), finalized #44 (0x16d0…cca3), ⬇ 0 ⬆ 0
2021-06-28 19:21:05 💤 Idle (0 peers), best: #47 (0xe84b…1339), finalized #45 (0x91ae…4dac), ⬇ 0 ⬆ 0
2021-06-28 19:21:06 🙌 Starting consensus session on top of parent 0xe84b108a4c0f8367350d3d94c4958542bc8f7c76f66834f23cb4092aef761339
2021-06-28 19:21:06 🎁 Prepared block for proposing at 48 [hash: 0x9219bfadc6afe3de3c9b9698881919893f8084c9a7fb6cfe10721b2f730a0e16; parent_hash: 0xe84b…1339; extrinsics (1): [0x9522…a62f]]
2021-06-28 19:21:06 🔖 Pre-sealed block for proposal at 48. Hash now 0x5690fe24203e0079f8cf07b5ce98a861c137847016ef22ec8712d9106ac0baf7, previously 0x9219bfadc6afe3de3c9b9698881919893f8084c9a7fb6cfe10721b2f730a0e16.
2021-06-28 19:21:06 ✨ Imported #48 (0x5690…baf7)
2021-06-28 19:21:10 💤 Idle (0 peers), best: #48 (0x5690…baf7), finalized #46 (0x2de2…646f), ⬇ 0 ⬆ 0
2021-06-28 19:21:12 🙌 Starting consensus session on top of parent 0x5690fe24203e0079f8cf07b5ce98a861c137847016ef22ec8712d9106ac0baf7
2021-06-28 19:21:12 🎁 Prepared block for proposing at 49 [hash: 0x6bcea7312e56e39bca111f6d1ae38e8770e04df6562b1bced44df4d19549d636; parent_hash: 0x5690…baf7; extrinsics (1): [0x5c5f…b9ad]]
2021-06-28 19:21:12 🔖 Pre-sealed block for proposal at 49. Hash now 0x0f05661dc12d63462fa877085494404a2f5bf5c86bf3b47c2872fae4d7f78891, previously 0x6bcea7312e56e39bca111f6d1ae38e8770e04df6562b1bced44df4d19549d636.
2021-06-28 19:21:12 ✨ Imported #49 (0x0f05…8891)
2021-06-28 19:21:15 💤 Idle (0 peers), best: #49 (0x0f05…8891), finalized #47 (0xe84b…1339), ⬇ 0 ⬆ 0
2021-06-28 19:21:18 🙌 Starting consensus session on top of parent 0x0f05661dc12d63462fa877085494404a2f5bf5c86bf3b47c2872fae4d7f78891
2021-06-28 19:21:18 🎁 Prepared block for proposing at 50 [hash: 0x01052da180894da1f9878ebd13eb60399863b72263032bd0ca68cf351840df38; parent_hash: 0x0f05…8891; extrinsics (1): [0xcfa7…0b31]]
2021-06-28 19:21:18 🔖 Pre-sealed block for proposal at 50. Hash now 0x9ea613dea0b494975b51252166a5cc54a3a3bb511b66245eaa55b3549cdd2b01, previously 0x01052da180894da1f9878ebd13eb60399863b72263032bd0ca68cf351840df38.
2021-06-28 19:21:18 ✨ Imported #50 (0x9ea6…2b01)
2021-06-28 19:21:20 💤 Idle (0 peers), best: #50 (0x9ea6…2b01), finalized #48 (0x5690…baf7), ⬇ 0 ⬆ 0
2021-06-28 19:21:24 🙌 Starting consensus session on top of parent 0x9ea613dea0b494975b51252166a5cc54a3a3bb511b66245eaa55b3549cdd2b01
2021-06-28 19:21:24 🎁 Prepared block for proposing at 51 [hash: 0x5c34f158548161bae48cd47e0f3e880c59d9d504dcf1c45cf159955d26581d9b; parent_hash: 0x9ea6…2b01; extrinsics (1): [0xc0ab…42f5]]
2021-06-28 19:21:24 🔖 Pre-sealed block for proposal at 51. Hash now 0x955578726185eb89bf908b1ee1f535937ce54c4ca055074dd63f9133a50cbacd, previously 0x5c34f158548161bae48cd47e0f3e880c59d9d504dcf1c45cf159955d26581d9b.
2021-06-28 19:21:24 ✨ Imported #51 (0x9555…bacd)
2021-06-28 19:21:25 💤 Idle (0 peers), best: #51 (0x9555…bacd), finalized #49 (0x0f05…8891), ⬇ 0 ⬆ 0
2021-06-28 19:21:30 🙌 Starting consensus session on top of parent 0x955578726185eb89bf908b1ee1f535937ce54c4ca055074dd63f9133a50cbacd
2021-06-28 19:21:30 🎁 Prepared block for proposing at 52 [hash: 0xce81a847ece90e4e2f03465226feb631dcfebb0baacbf6d9122104d2ccf03ee1; parent_hash: 0x9555…bacd; extrinsics (1): [0x4744…0c9c]]
2021-06-28 19:21:30 🔖 Pre-sealed block for proposal at 52. Hash now 0x9960395528406d3ab8d681a0a972e4c57d8fe46dbe8037fcaa2b141cc3a35c4c, previously 0xce81a847ece90e4e2f03465226feb631dcfebb0baacbf6d9122104d2ccf03ee1.
2021-06-28 19:21:30 ✨ Imported #52 (0x9960…5c4c)
2021-06-28 19:21:30 💤 Idle (0 peers), best: #52 (0x9960…5c4c), finalized #49 (0x0f05…8891), ⬇ 0 ⬆ 0
2021-06-28 19:21:35 💤 Idle (0 peers), best: #52 (0x9960…5c4c), finalized #50 (0x9ea6…2b01), ⬇ 0 ⬆ 0
2021-06-28 19:21:36 🙌 Starting consensus session on top of parent 0x9960395528406d3ab8d681a0a972e4c57d8fe46dbe8037fcaa2b141cc3a35c4c
2021-06-28 19:21:36 🎁 Prepared block for proposing at 53 [hash: 0x0a5e45f85efb4ce6a7621110cd447113efea7d0d40fc0657a2b5e5f4bdc0b441; parent_hash: 0x9960…5c4c; extrinsics (1): [0x1b47…11ab]]
2021-06-28 19:21:36 🔖 Pre-sealed block for proposal at 53. Hash now 0xda19c89fceb3205908c6f7919d75aa48b462adbe8eb8d0c3df75af4f47c58c7e, previously 0x0a5e45f85efb4ce6a7621110cd447113efea7d0d40fc0657a2b5e5f4bdc0b441.
2021-06-28 19:21:36 ✨ Imported #53 (0xda19…8c7e)
2021-06-28 19:21:40 💤 Idle (0 peers), best: #53 (0xda19…8c7e), finalized #51 (0x9555…bacd), ⬇ 0 ⬆ 0
2021-06-28 19:21:42 🙌 Starting consensus session on top of parent 0xda19c89fceb3205908c6f7919d75aa48b462adbe8eb8d0c3df75af4f47c58c7e
2021-06-28 19:21:42 🎁 Prepared block for proposing at 54 [hash: 0xe233a787be4c4c387dfb12999e677ce3669729eda9fa71a5a338b617216a157d; parent_hash: 0xda19…8c7e; extrinsics (1): [0x5b9c…bba2]]
2021-06-28 19:21:42 🔖 Pre-sealed block for proposal at 54. Hash now 0x76844d9af3fb36505e10d404b868f0b4603297b1bc286e3ece542f7a315acf2a, previously 0xe233a787be4c4c387dfb12999e677ce3669729eda9fa71a5a338b617216a157d.
2021-06-28 19:21:42 ✨ Imported #54 (0x7684…cf2a)
2021-06-28 19:21:45 💤 Idle (0 peers), best: #54 (0x7684…cf2a), finalized #52 (0x9960…5c4c), ⬇ 0 ⬆ 0
2021-06-28 19:21:48 🙌 Starting consensus session on top of parent 0x76844d9af3fb36505e10d404b868f0b4603297b1bc286e3ece542f7a315acf2a
2021-06-28 19:21:48 🎁 Prepared block for proposing at 55 [hash: 0xccd884f68d3596284bb1a7390a301792e093c47135f147977dca1a647ae83188; parent_hash: 0x7684…cf2a; extrinsics (1): [0xee71…d3d2]]
2021-06-28 19:21:48 🔖 Pre-sealed block for proposal at 55. Hash now 0x17484df01ede6ac52389033b9a5499b5489e596d4d31c87740d1befbbea09fbc, previously 0xccd884f68d3596284bb1a7390a301792e093c47135f147977dca1a647ae83188.
2021-06-28 19:21:48 ✨ Imported #55 (0x1748…9fbc)
2021-06-28 19:21:50 💤 Idle (0 peers), best: #55 (0x1748…9fbc), finalized #53 (0xda19…8c7e), ⬇ 0 ⬆ 0
2021-06-28 19:21:54 🙌 Starting consensus session on top of parent 0x17484df01ede6ac52389033b9a5499b5489e596d4d31c87740d1befbbea09fbc
2021-06-28 19:21:54 🎁 Prepared block for proposing at 56 [hash: 0x67457e162b8b81c7dec9df35930fb41cdd6e611392c95973825d6315550ed7b1; parent_hash: 0x1748…9fbc; extrinsics (1): [0xe9e8…c4a9]]
2021-06-28 19:21:54 🔖 Pre-sealed block for proposal at 56. Hash now 0x5dea5cb09e89d7fcbe2b3b310d42ad08b4f72826a6d1389327e823105d5c608e, previously 0x67457e162b8b81c7dec9df35930fb41cdd6e611392c95973825d6315550ed7b1.
2021-06-28 19:21:54 ✨ Imported #56 (0x5dea…608e)
2021-06-28 19:21:55 💤 Idle (0 peers), best: #56 (0x5dea…608e), finalized #54 (0x7684…cf2a), ⬇ 0 ⬆ 0
2021-06-28 19:22:00 🙌 Starting consensus session on top of parent 0x5dea5cb09e89d7fcbe2b3b310d42ad08b4f72826a6d1389327e823105d5c608e
2021-06-28 19:22:00 🎁 Prepared block for proposing at 57 [hash: 0x5c0b11d83439567982ce732d524b3ca2ef349941d70a5f2303660f26968a179e; parent_hash: 0x5dea…608e; extrinsics (1): [0x8fbb…1138]]
2021-06-28 19:22:00 🔖 Pre-sealed block for proposal at 57. Hash now 0x155ba5ccb02102c6132847f3fc0591831e129d31a092b0650e311768577ef506, previously 0x5c0b11d83439567982ce732d524b3ca2ef349941d70a5f2303660f26968a179e.
2021-06-28 19:22:00 ✨ Imported #57 (0x155b…f506)
2021-06-28 19:22:00 💤 Idle (0 peers), best: #57 (0x155b…f506), finalized #55 (0x1748…9fbc), ⬇ 0 ⬆ 0
2021-06-28 19:22:05 💤 Idle (0 peers), best: #57 (0x155b…f506), finalized #55 (0x1748…9fbc), ⬇ 0 ⬆ 0
2021-06-28 19:22:06 🙌 Starting consensus session on top of parent 0x155ba5ccb02102c6132847f3fc0591831e129d31a092b0650e311768577ef506
2021-06-28 19:22:06 🎁 Prepared block for proposing at 58 [hash: 0x859536d22737d62baf1a2170d6889c32f2af5efccf380a4bb25cb7349ee8303c; parent_hash: 0x155b…f506; extrinsics (1): [0x9725…d4b9]]
2021-06-28 19:22:06 🔖 Pre-sealed block for proposal at 58. Hash now 0x46f197252053492bb0b71546e09c3432fe72e44c4b1df22bddfc2f95df4af9a3, previously 0x859536d22737d62baf1a2170d6889c32f2af5efccf380a4bb25cb7349ee8303c.
2021-06-28 19:22:06 ✨ Imported #58 (0x46f1…f9a3)
2021-06-28 19:22:10 💤 Idle (0 peers), best: #58 (0x46f1…f9a3), finalized #56 (0x5dea…608e), ⬇ 0 ⬆ 0
2021-06-28 19:22:12 🙌 Starting consensus session on top of parent 0x46f197252053492bb0b71546e09c3432fe72e44c4b1df22bddfc2f95df4af9a3
2021-06-28 19:22:12 🎁 Prepared block for proposing at 59 [hash: 0x1251ace2b8edeb52eb646b90bbfba3149bd728adbf2c1bee53a93f28c448b806; parent_hash: 0x46f1…f9a3; extrinsics (1): [0xa250…6679]]
2021-06-28 19:22:12 🔖 Pre-sealed block for proposal at 59. Hash now 0x83f2125c6dd48d79ba0e1eaf179169b97c43f98a9fcf016035fd524d31912161, previously 0x1251ace2b8edeb52eb646b90bbfba3149bd728adbf2c1bee53a93f28c448b806.
2021-06-28 19:22:12 ✨ Imported #59 (0x83f2…2161)
2021-06-28 19:22:15 💤 Idle (0 peers), best: #59 (0x83f2…2161), finalized #57 (0x155b…f506), ⬇ 0 ⬆ 0
2021-06-28 19:22:18 🙌 Starting consensus session on top of parent 0x83f2125c6dd48d79ba0e1eaf179169b97c43f98a9fcf016035fd524d31912161
2021-06-28 19:22:18 🎁 Prepared block for proposing at 60 [hash: 0xaa76e40776de86b9882ae1ee697f640c838d263eb434ba3b73ce849758038e0f; parent_hash: 0x83f2…2161; extrinsics (1): [0xdb14…6769]]
2021-06-28 19:22:18 🔖 Pre-sealed block for proposal at 60. Hash now 0xb4da3ab935fc94852aaad8d8ba1001c7e109d3e926dacfb741363a6fc67cd3dc, previously 0xaa76e40776de86b9882ae1ee697f640c838d263eb434ba3b73ce849758038e0f.
2021-06-28 19:22:18 ✨ Imported #60 (0xb4da…d3dc)
2021-06-28 19:22:20 💤 Idle (0 peers), best: #60 (0xb4da…d3dc), finalized #58 (0x46f1…f9a3), ⬇ 0 ⬆ 0
2021-06-28 19:22:24 🙌 Starting consensus session on top of parent 0xb4da3ab935fc94852aaad8d8ba1001c7e109d3e926dacfb741363a6fc67cd3dc
2021-06-28 19:22:24 🎁 Prepared block for proposing at 61 [hash: 0x96078e836becc13039b45a597f63ca474f6c12937bf3eae67697d1f7e8e46d60; parent_hash: 0xb4da…d3dc; extrinsics (1): [0xec49…14f4]]
2021-06-28 19:22:24 🔖 Pre-sealed block for proposal at 61. Hash now 0xad06b647b20e9e3dae784aa061202b2f088a6345616e8eb32d9445b627d4c838, previously 0x96078e836becc13039b45a597f63ca474f6c12937bf3eae67697d1f7e8e46d60.
2021-06-28 19:22:24 ✨ Imported #61 (0xad06…c838)
2021-06-28 19:22:25 💤 Idle (0 peers), best: #61 (0xad06…c838), finalized #59 (0x83f2…2161), ⬇ 0 ⬆ 0
2021-06-28 19:22:30 🙌 Starting consensus session on top of parent 0xad06b647b20e9e3dae784aa061202b2f088a6345616e8eb32d9445b627d4c838
2021-06-28 19:22:30 🎁 Prepared block for proposing at 62 [hash: 0xc4fcd7a025bee0103d0f73d8b6d741ec7032aab94aefbacf426a366a7f64f7b8; parent_hash: 0xad06…c838; extrinsics (1): [0xa922…e29d]]
2021-06-28 19:22:30 🔖 Pre-sealed block for proposal at 62. Hash now 0x5cf84e19069127ab9147ebe72d66d63af17fe349a89dbc080324fbd4b32a0322, previously 0xc4fcd7a025bee0103d0f73d8b6d741ec7032aab94aefbacf426a366a7f64f7b8.
2021-06-28 19:22:30 ✨ Imported #62 (0x5cf8…0322)
2021-06-28 19:22:30 💤 Idle (0 peers), best: #62 (0x5cf8…0322), finalized #59 (0x83f2…2161), ⬇ 0 ⬆ 0
2021-06-28 19:22:35 💤 Idle (0 peers), best: #62 (0x5cf8…0322), finalized #60 (0xb4da…d3dc), ⬇ 0 ⬆ 0
2021-06-28 19:22:36 🙌 Starting consensus session on top of parent 0x5cf84e19069127ab9147ebe72d66d63af17fe349a89dbc080324fbd4b32a0322
2021-06-28 19:22:36 🎁 Prepared block for proposing at 63 [hash: 0x16c2f36d2ffc355cf93cb180fb3b7197f692e208f59a6c25dd10fdecad3c7440; parent_hash: 0x5cf8…0322; extrinsics (1): [0xb687…6426]]
2021-06-28 19:22:36 🔖 Pre-sealed block for proposal at 63. Hash now 0xedb19d234413bd23d4bfb75196cd588cb6547449e3fe6452310ed1b1445281fb, previously 0x16c2f36d2ffc355cf93cb180fb3b7197f692e208f59a6c25dd10fdecad3c7440.
2021-06-28 19:22:36 ✨ Imported #63 (0xedb1…81fb)
2021-06-28 19:22:40 💤 Idle (0 peers), best: #63 (0xedb1…81fb), finalized #61 (0xad06…c838), ⬇ 0 ⬆ 0
2021-06-28 19:22:42 🙌 Starting consensus session on top of parent 0xedb19d234413bd23d4bfb75196cd588cb6547449e3fe6452310ed1b1445281fb
2021-06-28 19:22:42 🎁 Prepared block for proposing at 64 [hash: 0x8e6ed7d1ef7a683adc21f54cd6eb2875a960ef75cd0272efc7ccff6f9ea647af; parent_hash: 0xedb1…81fb; extrinsics (1): [0x3396…beb8]]
2021-06-28 19:22:42 🔖 Pre-sealed block for proposal at 64. Hash now 0xfc704349d84f653b9747026f1366ca48454d78905cddff5119b0710088649c00, previously 0x8e6ed7d1ef7a683adc21f54cd6eb2875a960ef75cd0272efc7ccff6f9ea647af.
2021-06-28 19:22:42 ✨ Imported #64 (0xfc70…9c00)
2021-06-28 19:22:45 💤 Idle (0 peers), best: #64 (0xfc70…9c00), finalized #62 (0x5cf8…0322), ⬇ 0 ⬆ 0
2021-06-28 19:22:48 🙌 Starting consensus session on top of parent 0xfc704349d84f653b9747026f1366ca48454d78905cddff5119b0710088649c00
2021-06-28 19:22:48 🎁 Prepared block for proposing at 65 [hash: 0x4011ce0ecf4293e5000159529ff8c97e8b5e257ab40d61c8dec772d51cf873b6; parent_hash: 0xfc70…9c00; extrinsics (1): [0x19f4…cda2]]
2021-06-28 19:22:48 🔖 Pre-sealed block for proposal at 65. Hash now 0xf1d85ebafb5c00befb9ca6e6eedea290f0422c359055e222500cf738d2866350, previously 0x4011ce0ecf4293e5000159529ff8c97e8b5e257ab40d61c8dec772d51cf873b6.
2021-06-28 19:22:48 ✨ Imported #65 (0xf1d8…6350)
...
Start the Front-End Template
为了与您的本地节点进行交互,我们将使用 the Substrate Developer Hub Front-End Template,这是一个 UI 组件的集合,这些组件的设计考虑了常见的用例。
一定要使用与模板的正确版本substrate的版本使用的是作为主要的版本都没有预期到可互操作的!
一定要使用与正在使用的substrate的版本相对应的正确版本的模板,因为主版本是不希望被互操作的。
您已经安装了前端模板;让我们通过在前端模板的根目录中执行以下命令来启动它:
# Make sure to run this command in the root directory of the Front-End Template
yarn start
启动成功时,log输出如下:
Compiled successfully!
You can now view substrate-front-end-template in the browser.
Local: http://localhost:8000/substrate-front-end-template
On Your Network: http://192.168.1.190:8000/substrate-front-end-template
Note that the development build is not optimized.
To create a production build, use yarn build.
自动打开的web页面如下:
Interact
一旦前端模板运行并加载到您的浏览器 http://localhost:8000/ 中,请花点时间探索其组件。在顶部,您会找到许多有关您所连接的链的有用信息以及一个帐户选择器,可让您控制用于执行链上操作的帐户。
还有一个表格列出了您有权访问的已知的测试帐户。有些人,比如 Alice 和 Bob,已经有了资金!
在账户表下方有一个转账组件,您可以使用它来将资金从一个账户转移到另一个账户。记下描述前端模板使用的精度的信息框;你至少应该转移一下1000000000000,让你更容易观察你所做的改变。在这里,我们为dave开发账户提供这些资金:
请注意,账户的表格是动态的,此外,一旦转账被处理,账户余额就会更新。
Runtime Metadata
前端模板公开了许多有用的功能,您应该在连接到本地开发节点时探索所有这些功能。一种入门的好方法是单击模板页面顶部的“Show Metadata”按钮并查看 运行时公开的元数据。
Pallet Interactor & Events
您可以使用运行时元数据来发现运行时的功能。前端模板提供了一个有用的 Pallet Interactor 组件,该组件提供了多种与 Substrate 运行时交互的机制。
Extrinsics 是运行时的可调用函数;如果您已经熟悉区块链的概念,您现在可以将它们视为交易。Pallet Interactor 允许您提交 未签名 或 已签名 的extrinsics,还提供了一个按钮,可以通过 Sudo 托盘中的sudo函数 轻松调用一笔 extrinsic 。您可以在 Add a Pallet 教程中了解有关使用“SUDO”按钮调用特权extrinsics的更多信息。
您可以选择查询交互来读取 运行时存储中存在的值。RPC 和 Constant 选项为运行时交互提供了额外的机制。
像许多区块链一样,Substrate区块链使用事件来报告异步操作的结果。如果您已经使用前端模板执行上面描述的余额转账,您应该会在 Pallet Interactor 旁边的 Event 组件中看到一个转账事件。
Next Steps
🎉 祝贺 你!!!🎉
您已经启动了一个基于Substrate的区块链,并将一个用户UI界面连接到该区块链,并在用户之间进行tokens转账。我们希望你能继续学习Substrate!
你的下一步可能是:
在 Add a Pallet 教程中扩展模板节点的功能。
在 Forkless Upgrade a Chain 教程中了解无分叉运行时升级区块链。
如果您在本教程中遇到任何问题或希望提供反馈,您可以在Stack Overflow上提出问题,并使用substrate标签,或者与我们在 Element 上联系。
相关内容:
extrinsics:Substrate Extrinsics——外来的上链信息
[教程] 创建第一条 Substrate 链