2020-06-19 11:06:30 +00:00
[![Try on playground ](https://img.shields.io/badge/Playground-node_template-brightgreen?logo=Parity%20Substrate )](https://playground-staging.substrate.dev/?deploy=node-template)
2020-06-17 12:16:26 +00:00
2019-08-31 18:47:13 +00:00
# Substrate Node Template
2020-06-27 16:14:55 +00:00
A new FRAME-based Substrate node, ready for hacking :rocket:
2019-08-31 18:47:13 +00:00
2020-06-27 16:14:55 +00:00
## Local Development
Follow these steps to prepare your local environment for Substrate development :hammer_and_wrench:
### Simple Method
You can install all the required dependencies with a single command (be patient, this can take up
to 30 minutes).
```bash
curl https://getsubstrate.io -sSf | bash -s -- --fast
```
### Manual Method
Manual steps for Linux-based systems can be found below; you can
[find more information at substrate.dev ](https://substrate.dev/docs/en/knowledgebase/getting-started/#manual-installation ).
2019-08-31 18:47:13 +00:00
Install Rust:
```bash
curl https://sh.rustup.rs -sSf | sh
```
2019-10-20 12:22:24 +00:00
Initialize your Wasm Build environment:
2019-08-31 18:47:13 +00:00
```bash
./scripts/init.sh
```
2020-06-27 16:14:55 +00:00
### Build
Once you have prepared your local development environment, you can build the node template. Use this
command to build the [Wasm ](https://substrate.dev/docs/en/knowledgebase/advanced/executor#wasm-execution )
and [native ](https://substrate.dev/docs/en/knowledgebase/advanced/executor#native-execution ) code:
2019-08-31 18:47:13 +00:00
```bash
2019-10-20 12:22:24 +00:00
cargo build --release
2019-08-31 18:47:13 +00:00
```
2020-06-27 16:14:55 +00:00
## Playground [![Try on playground](https://img.shields.io/badge/Playground-node_template-brightgreen?logo=Parity%20Substrate)](https://playground-staging.substrate.dev/?deploy=node-template)
[The Substrate Playground ](https://playground-staging.substrate.dev/?deploy=node-template ) is an
online development environment that allows you to take advantage of a pre-configured container
with pre-compiled build artifacts :woman_cartwheeling:
2019-08-31 18:47:13 +00:00
## Run
2020-01-08 03:54:10 +00:00
### Single Node Development Chain
2019-08-31 18:47:13 +00:00
2020-01-06 20:58:38 +00:00
Purge any existing developer chain state:
2019-08-31 18:47:13 +00:00
```bash
2019-10-20 12:22:24 +00:00
./target/release/node-template purge-chain --dev
```
Start a development chain with:
```bash
./target/release/node-template --dev
2019-08-31 18:47:13 +00:00
```
2020-06-27 16:14:55 +00:00
Detailed logs may be shown by running the node with the following environment variables set:
`RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --dev` .
2019-08-31 18:47:13 +00:00
2020-01-08 03:54:10 +00:00
### Multi-Node Local Testnet
2019-08-31 18:47:13 +00:00
2020-06-27 16:14:55 +00:00
If you want to see the multi-node consensus algorithm in action, refer to
[our Start a Private Network tutorial ](https://substrate.dev/docs/en/tutorials/start-a-private-network/ ).
2020-01-08 03:54:10 +00:00
2020-05-15 04:27:30 +00:00
### Run in Docker
2020-06-27 16:14:55 +00:00
First, install [Docker ](https://docs.docker.com/get-docker/ ) and
[Docker Compose ](https://docs.docker.com/compose/install/ ).
2020-05-15 05:03:54 +00:00
Then run the following command to start a single node development chain.
2020-05-15 04:27:30 +00:00
```bash
./scripts/docker_run.sh
```
2020-06-27 16:14:55 +00:00
This command will firstly compile your code, and then start a local development network. You can
also replace the default command (`cargo build --release & & ./target/release/node-template --dev --ws-external`)
by appending your own. A few useful ones are as follow.
2020-05-15 04:27:30 +00:00
```bash
2020-05-15 05:03:54 +00:00
# Run Substrate node without re-compiling
2020-05-15 04:27:30 +00:00
./scripts/docker_run.sh ./target/release/node-template --dev --ws-external
2020-05-15 05:03:54 +00:00
# Purge the local dev chain
2020-05-15 04:27:30 +00:00
./scripts/docker_run.sh ./target/release/node-template purge-chain --dev
2020-05-15 05:03:54 +00:00
# Check whether the code is compilable
2020-05-15 04:27:30 +00:00
./scripts/docker_run.sh cargo check
```