Rise In Logo

Polkadot Fundamentals and Substrate Development


We now have a good understanding of Substrate, how it works and the features it provides us with. It’s now time to start building and in the following sections we will build some hands-on projects with substrate and before we get started, it is important to have Substrate installed on our system.

And we will go through the installation for each operating system.

Rust Toolchain

Substrate is built on Rust and hence knowledge of Rust is mandatory before you can build projects with Rust. In case you want to quickly learn Rust before starting the following projects, you can checkout “The Rust Programming Language” - this is the official documentation and is also a popular book to learn Rust.

The core tools in the Rust toolchain are the rustc compiler, the cargo build and package manager, and the rustup toolchain manager. 

At any given point in time, there can multiple versions of Rust available. For example, there are release channels for stable, beta, and nightly builds. You use the rustup program to manage the builds available in your environment and the versions of the toolchain programs that are used with different Rust builds.

Linux Installation

We first need the build-essentials package in Linux. We’re going to follow the guide for debian distributions, feel free to change the commands based on your distribution.

sudo apt install build-essential

Run this bash command to install a few more packages that will help us to work with Rust - 

sudo apt install --assume-yes git clang curl libssl-dev protobuf-compiler

Rustup is a toolchain manager that enables us to manage the different builds for Rust. Now we will download the rustup package and use it to install Rust - 

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Update your current shell to include cargo by running the following command - 

source $HOME/.cargo/env

Verify your installation by running the following command - 

rustc --version

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 to your development environment by running the following commands:

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

Verify the configuration of your development environment by running the following command:

rustup show
rustup +nightly show

Mac Installation

For mac, we will be leveraging the homebrew package manager. In case you don’t have it, you can install it with this command - 

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

You can the verify whether it’s been installed - 

brew --version

Since substrate blockchains require standard cryptography to support the generation of private and public keys pairs, we need to install the openssl package.

First let’s update the brew package - 

brew update

Then install the openssl package- 

brew install openssl

Now we can go ahead and install the rustup package that manages the various versions of Rust for us - 

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Update the current shell to include cargo - 

source ~/.cargo/env

After this point, follow all the instructions from the linux installation from rustc - -version onwards

Windows Installation

Working with Rust and substrate directly in windows is not recommended as it can be highly unstable. So go ahead and get the windows subsystem for Linux, also called as WSL, and it enables you to run Linux shells inside windows.

Run the following command to install WSL - 

wsl --install

Review the linux distributions available - 

wsl --list --online

Open up a linux terminal once you have WSL installed and then run the following command.

Download the latest updates of linux - 

sudo apt update

Install the packages that are needed - 

sudo apt install --assume-yes git clang curl libssl-dev llvm libudev-dev make protobuf-compiler

After this command, you can follow along with by running the same commands that were mentioned in the Linux installation guide since we have now opened a linux shell inside windows and the process will be exactly the same.

Rise In Logo

Rise together in web3