Substrate是由Parity科技公司研發的區塊鏈架構開發平台,具有完全通用的狀態轉換功能(State Transition Function, STF),和模塊化組件,實現了共識,網絡和配置。
本文主要將配置和運行第一個基於Substrate的區塊鏈。
安裝環境為virtual box 內的ubuntu 18 虛擬機。 需要安裝兩個倉庫項目
- substrate-node-template 主要是運行單機node的后台代碼
- substrate-front-end-template 提供一個前端ui的界面,可以看到node的運行情況
整個項目跑起來,前端UI如下圖所示
安裝相關依賴和npm比較麻煩點,具體如下:
- 安裝rust
- 安裝依賴: https://substrate.dev/docs/zh-CN/knowledgebase/getting-started/
- 安裝npm: https://github.com/nodesource/distributions/blob/master/README.md#debinstall
- 安裝yarn: npm install -g yarn
解決本地機器訪問虛擬機內的web
項目默認是本地運行的,只接受localhost的訪問。改其他ip訪問需要改動兩個地方
- node-template 啟動命令增加 --ws-external, 完整命令
./target/release/node-template --dev --tmp --ws-external
- 修改substrate-front-end-template 配置,將src/config/development.json 中的PROVIDER_SOCKET 由
ws://127.0.0.1:9944
改為ws://虛擬機ip:9944