Skip to content
This repository has been archived by the owner on Jul 4, 2022. It is now read-only.

Build a new project with PL^G

Jordan edited this page Sep 22, 2020 · 2 revisions

<- Back to Installing Dev Environment

This guide shows you how to run a node in development mode. This mode is ideal for testing and getting started with PL^G, because it comes preconfigured with a bunch of test accounts with funds.

1. Clone it

git clone -b 1.0.0-rc4.2 https://github.com/plugblockchain/plug-blockchain.git

2. Build it

cd plug-blockchain/bin/node-template/
cargo build -p node-template

3. Run it

This will run the built PL^G node. The purge-chain command ensures the node runs a fresh blockchain ledger.

The --validator and --alice flags set up the node as a development-chain authorised validator so that it will start producing blocks on its own.

../../target/debug/node-template purge-chain
../../target/debug/node-template --chain=dev --base-path=/tmp/plug-test --validator --alice

You may have to replace the --base-path with a valid path on your OS.

You should see something similar to:

20xx-xx-xx 12:17:34 Substrate Node
20xx-xx-xx 12:17:34   version 2.0.0-alpha.5-ffffffff-x86_64-macos
20xx-xx-xx 12:17:34   by Anonymous, 2017-2020
20xx-xx-xx 12:17:34 πŸ“‹ Chain specification: Development
20xx-xx-xx 12:17:34 🏷 Node name: pricey-roof-2938
20xx-xx-xx 12:17:34 πŸ‘€ Roles: AUTHORITY
20xx-xx-xx 12:17:35 πŸ”¨ Initializing Genesis block/state (state: 0x2c98…8264, header-hash: 0x334b…c99f)
20xx-xx-xx 12:17:35 Loading GRANDPA authority set from genesis on what appears to be first startup.
20xx-xx-xx 12:17:35 Loaded block-time = 6000 milliseconds from genesis on first-launch
20xx-xx-xx 12:17:35 πŸ“¦ Highest known block at #0

4. Configure it!

Navigate to node-template/node/src/main.rs

Change the sc_cli::VersionInfo:

name: "Awesome Node",
commit: env!("VERGEN_SHA_SHORT"),
version: env!("CARGO_PKG_VERSION"),
executable_name: "awesome-node",
author: "Peter Parker",
description: "Node to run on the decentralised Awesome network",
support_url: "support.awesome.io",
copyright_start_year: 2099,

In the node/Cargo.toml file change the following:

[package]
name = "awesome-node"

[[bin]]
name = "awesome-node"

Compile and run it again - this time the binary has changed to awesome-node

cargo build -p awesome-node
../../target/debug/awesome-node purge-chain
../../target/debug/awesome-node --chain=dev --base-path=/tmp/awesome-test --validator --alice

You should now see your "Awesome node":

20xx-xx-xx 12:35:21 Awesome Node
20xx-xx-xx 12:35:21   version 2.0.0-alpha.5-54c2032ff-x86_64-macos
20xx-xx-xx 12:35:21   by Peter Parker, 2099-2020
20xx-xx-xx 12:35:21 πŸ“‹ Chain specification: Development
20xx-xx-xx 12:35:21 🏷 Node name: womanly-activity-3970
20xx-xx-xx 12:35:21 πŸ‘€ Roles: AUTHORITY
20xx-xx-xx 12:35:31 πŸ”¨ Initializing Genesis block/state (state: 0x2c98…8264, header-hash: 0x334b…c99f)
20xx-xx-xx 12:35:31 Loading GRANDPA authority set from genesis on what appears to be first startup.
20xx-xx-xx 12:35:31 Loaded block-time = 6000 milliseconds from genesis on first-launch
20xx-xx-xx 12:35:31 πŸ“¦ Highest known block at #0

5. A brief tour of the node-template

The node template has a few important files:

  • node/src/main.rs - This is where you configure binary details (like in step 4)
  • node/Cargo.toml - Contains the binary build configuration
  • runtime/src/lib.rs - This is where we configure many of the features of your PL^G blockchain

Back to Installing Dev Environment

Next: Interact with the Blockchain