Basics of a simple substrate project

Bhaskar Dutta
3 min readMay 14, 2021

Are you a cat person or a dog person? Or do you have your own favorite animal as a pet? Let’s design a blockchain-based voting system for pets and settle this battle of cuteness.

Source: boredpanda.com

What are we building?

We will be building an independent blockchain that enables voting on uploaded pictures. This would simulate an online voting environment with a start and end time.

Our framework of choice will be Substrate. In some future articles, I will discuss what can be the reasons for choosing Substrate and its pros and cons, so follow me to stay updated.

What are pallets?

The Substrate framework is highly modular in design. Pallets can be considered as lego blocks. You can use a combination of already published pallets or create your own pallet and include it in your “Runtime”. If you want to build an NFT, there is a pallet for that. You want a multi-sig feature, there is a pallet for that too. Like a child playing with Lego, with this modular design of using pallets, your imagination is the limit.

In this series, we will build our own Pallet which will have the “main code” for online voting. This pallet then can be included in the Runtime and used in our blockchain.

“included in the Runtime,” you said…

You can think of Runtime as the main crux of your blockchain. Think of runtime as the final house you build with your Legos. The pallets we design or want to use have to be included in the runtime. This runtime is compiled to generate the executable which will run on all the computers wanting to connect with your blockchain.

On a very high level, you can think of Runtime as a skeleton of the node that will be running and pallets as the features or business logic you want in your blockchain. Adding a new feature is as simple as adding the required pallet.

Where is the smart contract in all this?

If you are from an Ethereum background, you must be wondering, where is the smart contract in all these shenanigans.

The Runtime (the skeleton of our node) does not support any smart contract by default. Business logic is added to the Runtime through Pallets. The Pallet contains the main code for our project.

There is also a Pallet for supporting Smart Contracts. Enabling smart contracts on our blockchain will enable users to build their own programs and run those on our blockchain. Since this comes with extra overhead, one should properly decide whether he/she wants to support smart contracts.

If your blockchain doesn’t require external users to write and deploy custom programs on top of it, then a better choice will be to design a pallet with all the business logic you want and including that pallet.

Since we want only the voting system to run on our blockchain, building a custom Pallet will be a wise choice.

Sorry, it got a bit boring…

Thanks if you made it this far. I know you have been waiting for the coding section and we are very close to it. Since now we are clear about what we are going to build and the basics of building projects using Substrate, it’s time to discuss our Pallet design. In the following article, we will be designing our pallet and then jump right into the code and get our hands dirty.

Follow to my next article here

If this article was helpful, kindly give it a clap. You can follow me to stay updated about my latest post and connect with me on LinkedIn.

--

--

Bhaskar Dutta

Blockchain Developer and Researcher looking forward to learning something new every day.