Skip to content
Snippets Groups Projects
README.md 3.08 KiB
Newer Older
Julien Eluard's avatar
Julien Eluard committed
[![Try on playground](https://img.shields.io/badge/Playground-node_template-brightgreen?logo=Parity%20Substrate)](https://playground-staging.substrate.dev/?deploy=node-template)
# Substrate Node Template

Dan Forbes's avatar
Dan Forbes committed
A new FRAME-based Substrate node, ready for hacking :rocket:
Dan Forbes's avatar
Dan Forbes committed
## 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).

Install Rust:

```bash
curl https://sh.rustup.rs -sSf | sh
```

Shawn Tabrizi's avatar
Shawn Tabrizi committed
Initialize your Wasm Build environment:

```bash
./scripts/init.sh
```

Dan Forbes's avatar
Dan Forbes committed
### 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:
Shawn Tabrizi's avatar
Shawn Tabrizi committed
cargo build --release
Dan Forbes's avatar
Dan Forbes committed
## 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:

### Single Node Development Chain
Ricardo Rius's avatar
Ricardo Rius committed
Purge any existing developer chain state:
Shawn Tabrizi's avatar
Shawn Tabrizi committed
./target/release/node-template purge-chain --dev
```

Start a development chain with:

```bash
./target/release/node-template --dev
Dan Forbes's avatar
Dan Forbes committed
Detailed logs may be shown by running the node with the following environment variables set:
`RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --dev`.
### Multi-Node Local Testnet
Dan Forbes's avatar
Dan Forbes committed
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/).
### Run in Docker

Dan Forbes's avatar
Dan Forbes committed
First, install [Docker](https://docs.docker.com/get-docker/) and
[Docker Compose](https://docs.docker.com/compose/install/).

Then run the following command to start a single node development chain.

```bash
./scripts/docker_run.sh
```

Dan Forbes's avatar
Dan Forbes committed
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.
# Run Substrate node without re-compiling
./scripts/docker_run.sh ./target/release/node-template --dev --ws-external

# Purge the local dev chain
./scripts/docker_run.sh ./target/release/node-template purge-chain --dev

# Check whether the code is compilable
./scripts/docker_run.sh cargo check
```