This article was originally posted by me on November 12, 2021 at thiscoindaily


Learning substrate could seem daunting at first, especially for those who are new to blockchain development. Even seasoned solidity developers are overwhelmed by the diverse possibilities substrate has to offer.

But it needn’t be that way.

If you follow a systematic path to understanding (and building with) substrate, you’ll quickly realize that it’s the best investment you could make in your career as a blockchain developer!

This article will guide you through an effective way to explore substrate. This is exactly what I did when I started out with substrate (with a few representing what I would have done), and it helped me connect the dots and understand the concepts better.

DisclaimerI’m still learning and can’t boast of being a rock-solid substrate developer. But I have a strong knowledge of the ecosystem, up to the level where I can pretty much replicate a majority of protocols out there and bring my own ideas to life (with some help of course!). If you can already do this but are looking to learn the nitty-gritty of writing the entire node and runtime from scratch, then this article is not for you.

This article assumes that you’re already a developer (likely in web 2.0 or solidity). If you’re just starting out as a developer, then check out the guides here and here to get started. (but you can still continue with this guide if you feel comfortable).

Still here? let’s get to it!

Step 1: The basics first!

The biggest mistake you could make when trying to learn substrate is jumping straight to complex topics in the doc without having some pre-requisites at hand. Even If you’re a seasoned web2.0 developer, you’d still find it hard if you jump right in without these pre-requisites.

Of course, you could ignore these pre-requisites altogether and jump right in, but you’d have a harder time implementing the concepts. And even when you do, there’s likely going to be a pragmatic difference between your codes and that of those who took their time to meet these pre-requisites first.

From my experience, the most important pre-requisites include,

A proper working environment

Sound obvious right?

It could be very demotivating to struggle with development tools right from the beginning, even before writing a single line of code. If you really want to program in substrate without any hassles, then by all means use a Linux operating system or a macOS.

That’s not to say that Windows wouldn’t be fine, (especially if you’d be using WSL2). But there’s a high tendency to run into some funny issues while using Windows. And I’m not an expert at troubleshooting, so I just stick with Linux.

For my IDE, I use vscode. It’s sophisticated enough for a lot of things

Now, that doesn’t mean you should get a new PC just to have access to Linux. You could dual boot Ubuntu on your machine. If that sounds like something too technical. you could use an online IDE called gitpod, which gives you access to an online version of vscode (this is very valuable if your PC’s RAM is on the lower side). As a matter of fact, I use gitpod a lot because that means I can write code anywhere (even if I’m not with my pc).

The only downside is Gitpod only gives you 50 hours of FREE coding time per month and you don’ have access to your localhost unless you do some SSH tweaks.

If you still feel Gitpod is too much of a hassle, you could just dive into substrate playground which has a couple of templates that you can start working on without having to set up any environment.

A good taste of what lays ahead

The aim here is to get yourself frustrated (intentionally!). This is especially important if you’re just starting out. You want to have a taste of what it takes to create pallets, implement them in the runtime, and get a blockchain node up and running as soon as possible.

Here’re the tutorials I’d suggest you brush through

The aim of going through the tutorials above is not to learn the codes and understand the nitty-gritty of what they do, but to,

  • Get an early feel of the problems you’re likely to run into.
  • Sensitize your brain with some patterns which would make sense as you move further.
  • Grant yourself a sense of gratification, mixed with frustration and confusion. This would stimulate your reticular activating center and grant you a lot of “Oh” and “Aha” moments as you move on to learn rust and more of substrate.

A good understanding of rust

Substrate was written in rust, which is an amazing language once you get to use it (but it used to be unpopular among developers).

The best resource you could use to learn rust the rust programming language book. Go through at least the first 10 chapters, while paying particular attention to things like traits/trait bounds, modules, structs (and their implementations), etc. These are heavily used in substrate.

Another thing I’d suggest you learn at this point is Macros (just a general understanding is enough). However, Macros aren’t covered in the first ten chapters)

If you have already done a couple of substrate tutorials, you’ll start noticing some patterns and mentally relating what you’re learning with what you worked on in those tutorials. this is gold!

Once you’re done with this, solve a couple of Rust exercises and go back to those tutorials you did before and watch the magic happen! things become a lot clearer and at this time, you’d have had a lot of motivation to go further and learn more!

A basic understanding of substrate

Substrate is a whole beast on its own, in the sense that it allows you to build almost anything! (you’re only limited by your imagination). To truly understand the capabilities of substrate and what you can do with it, you need to understand it from first principles.

I suggest going through substrate overview and architecture, as well the key concepts section of substrate docs

STEP TWO: BUILD AND TEST A CUSTOM PALLET FOR A VALID IDEA

To be honest, I only recently started building custom pallets for a pharma logistics blockchain that I’m working on. Before now, I’ve been using either pallets that were shipped with substrate or created by other developers.

That was a mistake!

If you try to create a custom pallet for an idea that you have, you will have a stronger understanding of how the components work together. you might fail of course (or you may create a crappy pallet). By doing this, you’d have explored a lot of resources, such that when you move to the next phase, you would know where things fit into. And when you come back to create a custom pallet, you’d be ready to get your hands dirty!

There are a couple of ways to look for ideas, but nothing beats reading about other people’s proposals and trying to implement them (that’s basically how the top blockchains were created). you could check google scholar for these proposals. You could as well check out implementations on other blockchains and try re-implementing them on substrate.

You don’t have to spend all your time on this step. The aim is not to come up with an incredible result (which is possible of course), but to get you ready for what’s to come.

STEP THREE: Go through the entire substrate DOC and how-to guides

At this point, you should have set up a couple of nodes and even attempted to bring your ideas to life. Now, it’s time to explore the docs. Pay particular attention to the “runtime development” section of the docs.

The aim is not to master everything here, but to gain a deeper understanding of the concepts and know exactly where to go when you run into problems.

As you go through the docs, you’ll quickly realize that you’re already familiar with a lot of the concepts. That’s the benefit of frustrating yourself beforehand. This is where you’ll get a large dose of “OH” and “aha” moments!

You should also glance through the how-go guides, which help guide you on the best principles for building on substrate. Don’t spend much time here, as you would be referring to this a lot of the time as you build your projects. The aim is to know where to find help when you need it.

Important: while going through the docs, there are concepts in rust that you might not be familiar with. Whenever you come across such concepts, go to the rust book and try understanding them before you move further. That way, you learn rust pari-passu with substrate, instead of learning one before the other.

STEP FOUR: BRING YOUR IDEAS TO LIFE

Don’t be scared! If you’ve come this far, then you have more than what it takes to implement your ideas on substrate. This doesn’t mean you won’t get frustrated anymore or wouldn’t need to refer to resources for help, but at least you know where/how to look for help.

Preferably, this should be a solid project. remember, one rock-solid project is better than 5 mediocre projects:

  • research your idea
  • Draft out a proof of concept
  • map out an architecture
  • map out functions you’ll need to implement
  • decide on pallets that are needed!
  • start up a template for your project
  • create custom pallets if needed
  • integrate your projects with the runtime
  • build your chain and interact with it using polkadotjs app (make sure everything is working fine)
  • build the front-end of your project
  • Share with the community

The project you build should be something that’s unique… something that’ll make you think. that’s how you learn. You can always replicate someone’s (open-source) project idea, but try to introduce something new and helpful.

Step five: Finish the rest of subtrate tutorials and keep learning

If you’ve come this far, then this should be the easiest (but most important) step.

You should go through the remaining substrate tutorials to learn concepts like starting a private network, performing forkless upgrades, developing smart contracts with ink!, launching a parachain with cummulus, etc.

As you go through these tutorials, brainstorm on how to apply them to your project. For example, you could decide to launch a smart contract implementation of your project on a parachain like moonbeam or launch a parachain on polkadot/kusama testnet.

If you did all of the above, you should be very proud of yourself. But the journey is just starting. now you’ll have to keep up with your skills. and the only way to do that is to build, make mistakes and build again. Also, watch out for new releases and learn to refer to relevant docs if you run into problems.

As you improve your skills and build projects, there are a couple of points to remember;

  • programming is all about breaking down a complex idea into as many simple parts as possible. These little problems can be solved in part and then coupled to form a whole solution.
  • As much as possible, try to create pallets that are re-usable for other use-cases.
  • learn to read other people’s codes. ask yourself questions about their codes (why did they choose particular design decisions? how can you implement their ideas in your code?).
  • Google is your friend! ask questions when you’re stuck!
  • A single solid project is better than 5 mediocre projects!
  • learn to experiment on your codes? Ask yourself what would happen if you did things differently.
  • Keep learning and updating yourself. Learning never ends!
  • Keep improving your skills in rust!
  • Get into the habit of showcasing your work on Github!

Conclusion

whew! That’s a lot to learn! It will take time, of course. But you’ll have yourself to thank for it, if you discipline yourself to actually go through these steps.

There’re easier ways to go about learning substrate of course. However, you’d only get comfortable at the beginning. Your frustration will surface when you start diving into more complex concepts and projects.

So, which do you prefer? Frustration after comfort, or frustration before comfort?

The easy way, or the hard way??

Share.

Comments are closed.