How to build a blockchain, rapidly.

0
41

How to build a blockchain, rapidly

A short, non-technical introduction to Substrate

Substrate, by Parity Technologies

What is Substrate and how did it come to be?

Parity (the company behind Substrate, founded by Gavin Wood) has had a lot of experience building blockchains. As an example, Parity worked on implementing the Polkadot blockchain.

As with most things, the moment you do one thing many times, you will find similarities between the different iterations of the thing that you’ve built. You will find easier, and more efficient ways of building them — batching, automation, etcetera.

With code, if you’re building blockchains repeatedly, you will find that some parts of a blockchain change little and they repeat themselves from blockchain to blockchain. (i.e. consensus algorithm, databases, etc.). This can be seen with multiple projects in the past (circa 2019 and before) where developers would be copy-pasting bits and pieces of code and in some cases, forking existing chains to make minor changes to the code to suit their needs. This is a solution, but as you would imagine, it isn’t a wonderful idea as you would still need to spend time and resources in understanding the code and how it interacts with the rest of the other blockchain that was written.

So whilst the Parity team was building Polkadot, they had this realisation and decided that the repeatability of certain parts of the blockchain could form a template or model for future creations. Hence, Substrate was born with the creation of an open-source repository with re-useable libraries to create a modular and extensible framework that’s required to build a blockchain.

So… What Is In a Blockchain?

A typical blockchain node would require:

  1. Database Layer — A storage backend to store all the blocks that have been authored on the network; to store the state of the blockchain)
  2. Networking Layer — A P2P networking layer so the nodes can communicate with other network participants on the transactions that take place and also to stay in sync.
  3. Consensus Engine — A way to agree on the state of the chain through proof-of-work (Bitcoin), proof-of-stake (Ethereum), nominated proof-of-stake (Polkadot), etc.
  4. Transaction Handling To handle any balance transfers or arbitrary transactions that may come into the blockchain to be processed.
  5. Runtime Logic — Whatever your chain does that makes it special. In Bitcoin the runtime is cryptocurrency. In Ethereum, the runtime is the EVM.

To write a blockchain you need usually know an expert or be an expert yourself in each one of the 5 elements above. However, depending on the application your blockchain is specialising in, that will play into the various expertise needed and some parts can be much more complex to engineer than other areas.

Nonetheless, all these factors usually meant that development of a blockchain project can take a really long time and can also be very costly, as you will need funds to hire all the experts that you need.

How can Substrate help?

The goal of Substrate is to ease the development process in creating a blockchain, so you can concentrate on purpose-building whatever that you sought to do.

The chief aim of Substrate is to allow for a Lego-like system of taking pieces of bricks out of the box to create a blockchain.

So if you want to create a proof-of-stake blockchain, you can pull out the modules that’s required and you can build on top of, or within, Substrate by writing your own code and adding your own ‘finishing touches’ to make that blockchain your own project.

Substrate FRAME pallets define the Runtime

The Runtime Logic of a blockchain defines its behaviour and what functionality it has. This makes the blockchain unique.

The core Substrate code base ships with FRAME — the system by which the runtime is developed. FRAME provides a framework that makes it easy to construct a runtime by composing modules, called “pallets”. Each of these pallets contains executable logic that serves its required function/purpose.

So, for example, if you want your blockchain to have proof of stake functions, you can choose the staking pallet. Or if you want your chain to have a pot of funds that can be used to develop additional features and upgrades or to maintain the chain, you can choose the treasury pallet. If you want some sort of on-chain governance, you can choose the democracy pallet. The full suite of pallets can be found here.

You get the picture now. It’s a very plug-and-play system that’s best of all code-customisable.

As proof of how rapidly you can build a blockchain, you can watch the genius-in-chief Gavin Wood doing so in less than 60 minutes using Substrate (on a brand new MacBook that he got on his way to the Web3 summit), instead of the usual days or weeks that’s traditionally required.

Projects being developed on Substrate

Substrate is one of the main reasons why the Polkadot blockchain has got so many projects springing up. The ease of use for developers to create new blockchains encourages a rapid-protyping environment to make and break things at a breakneck pace.

Of course, the mightiest of all projects that have been built on top of Substrate is Polkadot, as well as its canary network, Kusama.

Some of the more well-known projects that have been developed on Substrate are Chainlink (decentralised oracle network), Ocean Protocol(decentralised data-exchange protocol), Moonbeam (decentralised application interoperability) and Edgeware (smart contract platform).

As an example of Edgeware, almost all the code was implemented using Substrate to launch a working blockchain. The engineering effort for creating Edgeware was limited to mainly building the governance systems, and porting a pipeline for the existing Ethereum Virtual Machine (EVM) smart contracts to be run on Ethereum WebAssembly (Ewasm).

You can find out more about Substrate in the following links below.

https://www.substrate.io/

https://substrate.dev/

https://polkadot.network/chainlink-reaches-milestone-with-polkadot/

Join Coinmonks Telegram group and learn about crypto trading and investing

Also, Read

Get Best Software Deals Directly In Your Inbox

How to build a blockchain, rapidly. was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.