Substrate – A Blockchain Framework on Rust

Knoldus Blog Audio
Reading Time: 3 minutes

Substrate is a modular framework that enables you to create purpose-built blockchains by composing custom or pre-built components. It is powered by best-in-class cryptographic research and comes with peer-to-peer networking, consensus mechanisms, and much more. Because of the ease and good results, It is attracting more business towards itself. It is reliable, it is secure and fast at the same time. We will get to see in the future how it will eventually take over blockchain development projects.

This takes a modular approach to blockchain development and defines a rich set of primitives that allows developers to make use of powerful, familiar programming idioms. It is designed to be used in one of three ways, With Substrate Node , With Substrate FRAME, With Substrate Core.

Substrate design

Architecture:-

The Substrate’s client is an application that runs a Substrate-based blockchain node. It consists of several components that include, but are not limited to, the following:

  • Storage: used to persist the evolving state of a blockchain.It ships with a simple and highly efficient key-value storage mechanism.
  • Runtime: the logic that defines how blocks are processed, including state transition logic.
  • Peer-to-peer network: the capabilities that allow the client to communicate with other network participants. Substrate uses the Rust implementation of the libp2p network stack to achieve this.
  • Consensus: the logic that allows network participants to agree on the state of the blockchain. This framework makes it possible to supply custom consensus engines and also ships with several consensus mechanisms that have been built on top of Web3 Foundation research.
  • RPC (remote procedure call): the capabilities that allow blockchain users to interact with the network. It provides HTTP and WebSocket RPC servers.
  • Telemetry: client metrics that are exposed by the embedded Prometheus server.

Create Your First Substrate Chain

Set up in Ubuntu/Debian

Use a terminal shell to execute the following commands:

sudo apt update 

# May prompt for location information

sudo apt install -y git clang curl libssl-dev llvm libudev-dev

For most users you can run our script to automate the steps listed below:

curl https://getsubstrate.io -sSf | bash -s -- --fast

If this gives any errors, please follow the steps below to manually configure rust on your machine.

# Install

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

# Configure

source ~/.cargo/env

Configure the Rust toolchain to default to the latest stable version, add nightly and the nightly wasm target:

rustup default stable 

# update your Rust

rustup update

# update your Rust nightly

rustup update nightly 

# nightly wasm latest version

rustup target add wasm32-unknown-unknown --toolchain nightly

Compiling the Node Template:

Clone the Node Template (version v3.0.0+monthly-2021-05).

git clone -b v3.0.0+monthly-2021-05 --depth 1 https://github.com/substrate-developer-hub/substrate-node-template

Compile the Node Template

cd substrate-node-template 

# NOTE: you should always use the `–release` flag

cargo build --release 

# ^^ this will take a while!

Install the Front-End Template

To use the front-end template, you need Yarn, which itself requires Node.js. If you don’t have these tools, you must install them from these instructions:

Install Node.js

Install Yarn

Now you can proceed to set up the front-end template with these commands.

# Clone the frontend template from Github

 git clone -b v3.0.0+monthly-2021-05 --depth 1 https://github.com/substrate-developer-hub/substrate-front-end-template 

# Install the dependencies

cd substrate-front-end-template 
yarn install

This is how we make the substrate blockchain. Wasn’t that easy?

Stay tuned to explore more exciting topics !!

If you want to read more content like this? Subscribe to Rust Times Newsletter and receive insights and latest updates, bi-weekly, straight into your inbox. Subscribe to Rust Times Newsletter: https://bit.ly/2Vdlld7.


Knoldus-blog-footer-image

Written by 

Ayushi is a Software Developer having more than 1.5 year of experience in RUST. Her practice area is Rust and Go. She loves to solve daily coding challenges.

Leave a Reply