December 19, 2022

Polkadot and Substrate: How to Build a Custom Blockchain?

Talk To Our Consultant

In this tutorial, you’ll be going through the fundamentals of blockchain technology and Polkadot how it works, and the polkadot framework.

Next, we’ll move on to the installation, running, and compilation sections for rust using the substrate. After that, you’ll see how to build a custom blockchain using the substrate framework.

Moving further, you’ll learn how to create a bootnode and connect it to three other nodes.

If you are someone new to the blockchain, you must understand the concepts of Blockchain, Polkadot, and Substrate

For this tutorial, you should also be comfortable with command-line interfaces and program development in general.

The Basic Concept of Blockchain

Blockchain enables the real-time recording of data about any event or transaction through a distributed, decentralized, peer-to-peer ledger that is immutable and replicated across numerous nodes connected by a network. It is made up of links in a chain that are used to securely record digital assets. A digital chain composed of unchangeable data blocks stored on a decentralized and dispersed network of computers.

What are The 4 Types of Blockchain?

1. Public Blockchain

It is a distributed ledger that anyone can join and use to complete transactions. Every computer in the network has a copy of every other node or block in the network. We can also carry out transactions or record verification. Anybody with access to the internet and a computer with decent hardware can take part in this open blockchain.

Traditional financial systems can be replaced by public blockchains because they are secured by proof of work or proof of stake. The smart contract that allowed this blockchain to support decentralization represents its more advanced side. Bitcoin and Ethereum are two examples of public blockchains.

2. Private Blockchain

A blockchain network operates in a private setting, such as a restricted network, or is managed by a single identity. only selected nodes can participate in the process, making them more secure than the others.

This blockchain, with proper security and maintenance, is a great asset for securing information without exposing it to the public eye. As a result, businesses use them for internal auditing, voting, and asset management.

3. Hybrid Blockchain

Companies that want the best of both worlds use a hybrid blockchain, which combines the benefits of both private and public blockchains. some parts are controlled by one organization and others are made visible as a public blockchain.

It offers a more comprehensive solution to the healthcare industry, government, real estate, and financial firms. It provides a solution when data must be accessed publicly but must be protected privately.

4. Consortium Blockchain

A consortium blockchain, also known as a federated blockchain, has both private and public blockchain features, similar to how a hybrid blockchain does.

It has a lot of potential in companies, banks, and other payment processors. The organizations’ food tracking frequently collaborates with their sectors, making it a federated solution ideal for their use.


Its multichain network seeks to link various specialized blockchains into a single cohesive network. the blockchain that is linked to Polkadot and works in parallel blockchains known as parachains.

Polkadot combines a network of custom-built blockchains into a single network. Bridges are also used by Polkadot to link to legacy networks and the cousin network kusama. With a tool called substrate, the blockchain on Polkadot is custom-built and customized for certain needs.

Four major components of Polkadot:


It is the heart of Polkadot that’s responsible for the network’s shared security, consensus, and cross-chain interoperability. Interoperability refers to the ability of the diff-diff platform to operate as a single platform or as a reference platform.


A blockchain with the ability to issue its own tokens and tailor its features to particular use cases. Additionally, it is directly linked to the relay chain.


It’s similar to parachains, but on a pay-as-you-go basis. It is more cost-effective because blockchain does not require continuous network connectivity.


Blockchain bridges allow two economically sovereign and technologically diverse chains to communicate with each other.


It is a generic blockchain platform that offers plug-and-play components for creating blockchain networks and applications. The substrate chain was given the messaging protocols by the Polkadot network so they could communicate with one another.

In order to construct the runtime logic necessary for your blockchain, you can use, modify, and extend the modules referred to as pallets and support libraries provided by the FRAME development environment. For eg Aura, BABE, GRANDPA, Electrons, utility, Sudo, EVM, and more…

Three core technologies in substrate:


This will use the P2P(Peer-to-peer) stack for networking.

Wasm (Web assembly)

It is the key technology for the substrate nodes. Everything in runtime will compile in Web assembly. It is also known as the shell of the brain.


The Polkadot Relay Chain uses GRANDPA (GHOST-based Recursive ANcestor Deriving Prefix Agreement) as its finality device.

Blocks are finalized by the Polkadot Host using the GRANDPA Finality protocol. The validator nodes must vote in successive rounds in order to reach finality. In parallel with Block Production, Validators run the GRANDPA finality process as a separate service.

Custom Blockchain Development: Step-by-Step Process


Before you start digging into this installed Rust and configuring your development environment. We use Linux; if you are using a different platform, please refer to the official documentation of the substrate.

Rust is compatible with the vast majority of Linux distributions. You have to add some software dependencies to your environment. You have to install the build-essential.

Before installing Rust, the following packages are required:

sudo apt install build-essential
clang curl git make

Install the Basic tools for Rust

Connect to your computer and launch a terminal shell. Execute the command.

sudo apt install –assume-yes git clang curl libssl-dev
  • Download the rustup installation program and run the following command to install Rust.
curl –proto ‘=https’ –tlsv1.2 -sSf | sh
  • Cargo should be added to your current shell.
source $HOME/.cargo/env
  • Run the following command to validate your installation:
rustc –version
  • Run the following commands to set the Rust toolchain to launch with the most recent stable version:
rustup default stable
rustup update
  • Run the following commands to add the nightly release.
rustup update nightly
rustup target add wasm32-unknown-unknown –toolchain nightly
  • For Verification
rustup show
rustup +nightly show

Compilation of the Substrate Node Template

Let’s get started on the project after you finish the installation.

  1. Open a terminal shell on your computer.
  2. Run this command
git clone
  1. Change the root directory to substrate-node-template.
cd substrate-node-template
  1. Run the following command to compile the node template.
cargo build –release

To create optimal artifacts, always use the –release flag.

NOTE: If your installation is complete but you are receiving an error on this command, please select the most recent branch based on version.

Let’s move on to the next section if your build was running successfully.

  • Let’s get started with the local node:

Run the following command to put the node in development mode.

./target/release/node-template –dev


If your output looks like this, your local node is up and running.

The substrate node template also provides you with some sample users to use with their balances and different access levels. Which you can see in the users list. We will connect three nodes to the bootstrap node for these sample users.

That’s it! Following all the steps mentioned above, you can create your first custom blockchain on substrate.

Creating a Bootstrap Node (First Blockchain Node)

Let’s go through how to build a first blockchain node or a bootstrap node and connect it with the other nodes.

  1. First Purge old chain data:

To start a new node, we must first clear the data for that user before moving on.

./target/release/node-template purge-chain –base-path /tmp/alice –chain local

The command requests that you confirm the operation:

Are you sure to remove “/tmp/alice/chains/local_testnet/db”? [y/N]:

If you want to delete your old data, please choose y.

  1. Let’s get your first blockchain node up and running with Alice:

In this, a bootnode is created, to which all other nodes will connect.

./target/release/node-template \
–base-path /tmp/alice \
–chain local \
–alice \
–port 30333 \
–ws-port 9945 \
–rpc-port 9933 \
–node-key 0000000000000000000000000000000000000000000000000000000000000001 \
–telemetry-url “wss:// 0” \



specifies the location of all data associated with this chain.

chain local

Indicates the chain specification to be used. Local, development and staging are examples of valid predefined chain specifications.


Adds the Alice account’s predefined keys to the node’s Keystore. The Alice account is used for block production and finalization with this setting.

port 30333

Specifies the port to which peer-to-peer traffic should be routed. 9945 ws-port

Specifies the port to which incoming WebSocket traffic should be routed. 


Specifies the port to which incoming RPC traffic should be routed. 


This option specifies the Ed25519 secret key to be used for libp2p networking. This option should only be used for development and testing.


Specifies where telemetry data should be sent. For this tutorial, you can send telemetry data to a Parity-hosted server that anyone can use.


Indicates that this node participates in network block production and finalization.

  1. Your output will look like this after you run the command:

🔨 Initializing Genesis block/state (state: 0xf46a…f94a, header-hash: 0x530e…11a0): 

The initial or genesis block that the node is using is identified. Check that these values are the same when you start the next node.

🏷  Local node identity is: 12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp

This node’s unique string is specified. This key will also be used so that another node can connect to the Alice node.

💤 Idle (0 peers):

indicates that no other nodes are present in the network and that no blocks are being produced. Before blocks can be produced, another node must join the network.

  1. Run the bob account to launch a second local blockchain node:

Open the second terminal. Please clear out old chain data for Bob first. Also in the command you with comparing both commands for Alice and for bob you will see that they all have increments on a port, –ws-port, and –rpc-port.

./target/release/node-template \
–base-path /tmp/bob \
–chain local \
–bob \
–port 30334 \
–ws-port 9946 \
–rpc-port 9934 \
–telemetry-url “wss:// 0” \
–validator \
–bootnodes /ip4/

If you notice, we are using –bootnode in this command to connect with the Alice node using their locality, TCP port, and peer-to-peer connection we are using the key 12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp.

When you run the command, the output will look like this:

In the output, you can see that your node is now 💤 Idle (1 peers), which means that it is successfully connected to the Alice node.

  1. Run the charlie account to launch the next local blockchain node:
./target/release/node-template \
–base-path /tmp/charlie \
–chain local \
–charlie \
–port 30335 \
–ws-port 9947 \
–rpc-port 9935 \
–telemetry-url “wss:// 0” \
–validator \
–bootnodes /ip4/
  1. Run the eve account to launch the next local blockchain node:
./target/release/node-template \
–base-path /tmp/eve \
–chain local \
–eve \
–port 30336 \
–ws-port 9948 \
–rpc-port 9936 \
–telemetry-url “wss:// 0” \
–validator \
–bootnodes /ip4/

So that’s it. You have successfully built your custom blockchain with four nodes.

You can find your local node or custom node in the development section of the official website, after which you can change the network if you want to connect with the UI version.

Now you can see all the blocks and accounts, and you can create an account with a mnemonic as well. You can also transfer tokens and inspect and use pallets.


After going through the blog, you must have got an idea of what is polkadot and substrate. Also, following the step-by-step process listed above, you can create a custom blockchain and how to connect it with the 4 nodes.

For the latest updates and upcoming blogs, stay tuned to BlockTech Brew.

ALSO ON Blocktech Brew

Ask For A Free Demo!

Our Trusted Partners

Meet Our Allies In Building Innovative Solutions Fuelling Growth & Unbeatable Results

Collaboration is key to building innovative solutions that deliver unbeatable results. Our trusted partners and allies share our vision and values, allowing us to work towards common goals. By leveraging each other's strengths and expertise, we can create a powerful force for growth and success.


Have A Vision?

Share Your Idea Now & Step-Ahead With Innovative Blockchain Solutions.

Let’s Fire Up Your Business!

Team Up With Us Today For An Unforgettable Service Experience


Level- 26, Dubai World Trade Centre Tower,
Sheikh Rashid Tower, Sheikh Zayed Rd, Dubai, UAE

+971 55 473 8790


Plot no 5 CDCL Building,
Sector 28 B Chandigarh 160028

+91 771-966-6171


Av. Miguel Hidalgo y Costilla 1995, Arcos
Vallarta, 44600 Guadalajara, Mexico

+1 (332) 233-6033


401 Park Avenue South, 10th Floor
New York, NY 10016

+1 (332) 233-6033