Catalog
• What is Substrate?
• Install Rust and the Rust toolchain
• Prepare a Substrate node using the node template
• Install the front-end template
• Start the local Substrate node
• Start the front-end template
• Transfer funds from one account to another
• Stop the local node
• Substrate Tutorials , Substrate 教程
• Contact 联系方式
• What is Substrate?
Substrate is an open source, modular, and extensible framework for building blockchains.
Substrate has been designed from the ground up to be flexible and allow innovators to design and build a blockchain network that meets their needs. It provides all the core components you need to build a customized blockchain node.
To get you started, the Substrate Developer Hub provides an out-of-the-box working Substrate-based node template. Without making any changes, you can use this node template to create a working blockchain network with some predefined user accounts and funds.
• Install Rust and the Rust toolchain
To install and configure Rust manually:
- Install rustup by running the following command:
curl https://sh.rustup.rs -sSf | sh
- Configure your current shell to reload your PATH environment variable so that it includes the Cargo bin directory by running the following command:
source ~/.cargo/env
- Configure the Rust toolchain to default to the latest stable version by running the following commands:
rustup default stable
rustup update
- Add the nightly release and the nightly WebAssembly (wasm) targets by running the following commands:
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
- Verify your installation by running the following commands:
rustc --version
rustup show
The previous steps walked you through the installation and configuration of Rust and the Rust toolchain so that you could see the full process for yourself.
• Prepare a Substrate node using the node template
The Substrate node template provides a working development environment so that you can start building on Substrate right away.
To compile the Substrate node template:
- Clone the node template repository using the version latest branch by running the following command:
git clone https://github.com/substrate-developer-hub/substrate-node-template
- Change to the root of the node template directory by running the following command:
cd substrate-node-template
git checkout latest
- Compile the node template by running the following command:
cargo build --release
You should always use the --release flag to build optimized artifacts.
• Install the front-end template
- Clone the front-end template repository by running the following command:
git clone https://github.com/substrate-developer-hub/substrate-front-end-template
- Change to the root of the front-end template directory by running the following command:
cd substrate-front-end-template
git checkout latest
- Install the dependencies for the front-end template by running the following command:
yarn install
• Start the local Substrate node
- Change to the root directory where you compiled the Substrate node template. Start the node in development mode by running the following command:
./target/release/node-template --dev
- Verify your node is up and running successfully by reviewing the output displayed in the terminal.
The terminal should display output similar to this:
If the number after finalized is increasing, your blockchain is producing new blocks and reaching consensus about the state they describe.
We'll look into the details of what's reported in the log output in a later tutorial. For now, it's only important to know that your node is running and producing blocks.
- Keep the terminal that displays the node output open to continue.
• Start the front-end template
The Substrate front-end template consists of user interface components to enable you to interact with the Substrate node and perform a few common tasks.
To use the front-end template:
Open a new terminal shell on your computer, change to the root directory where you installed the front-end template.
Start the Front-end template by running the following command:
yarn start
- Open http://localhost:8000 in a browser to view the front-end template.
The top section has an Account selection list for selecting the account to work with when you want to perform on-chain operations. The top section of the template also displays information about the chain to which you're connected.
• Transfer funds from one account to another
Now that you have a blockchain node running on your local computer and you have a front-end template available for performing on-chain operations, you are ready to explore different ways to interact with the blockchain.
By default, the front-end template includes several components that allow you to try different common tasks. For this tutorial, you can perform a simple transfer operation that moves funds from one account to another.
To transfer funds to an account:
• Stop the local node
After a successful transfer, you can continue to explore the front-end template components or stop the local Substrate node. Because you specified the --dev option when you started the node, stopping the local node stops the blockchain and purges all persistent block data so that you can start with a clean state next time you start the node.
To stop the local Substrate node:
Return to the terminal shell where the node output is displayed.
Press Control-c to terminate the running process.
Verify your terminal returns to the terminal prompt in the substrate-node-template directory.
• Substrate Tutorials , Substrate 教程
CN 中文 Github Substrate 教程 : github.com/565ee/Substrate_CN
CN 中文 CSDN Substrate 教程 : blog.csdn.net/wx468116118
EN 英文 Github Substrate Tutorials : github.com/565ee/Substrate_EN
EN 英文 dev.to Substrate Tutorials : dev.to/565ee
• Contact 联系方式
Homepage : 565.ee
GitHub : github.com/565ee
Email : 565.eee@gmail.com
Facebook : facebook.com/565.ee
Twitter : twitter.com/565_eee
Telegram : t.me/ee_565
Top comments (0)