Setting Up Developer Environments for Polkadot and Substrate
Welcome, trailblazers! By now, we’ve dipped our toes into what Polkadot is and even have a cool project idea with CertiDOT. But what’s a builder without their tools? Lesson 3 is all about gearing us up with the right development environment so we can craft dApps and blockchains like pros.
Why Setting Up Matters
Before jumping into the action, let’s talk about why setting up our environment properly is critical. A well-oiled setup not only saves time but also reduces frustration. With Polkadot and Substrate’s ecosystem being vast, a good foundation ensures smooth sailing later. Plus, the tools we set up today will stay with us throughout this journey.
Tool #1: polkadot.js – The Power Console
Polkadot.js is a suite of tools, not just a browser extension. It provides a robust interface to interact with the Polkadot ecosystem, including account management, network interactions, and even smart contract operations. We’ll focus on two key components: The Browser Extension and The Hosted App.
The Browser Extension:
The Hosted App:
IPFS Version: The Polkadot.js app also offers an IPFS-hosted version. While may not be completely in sycn with the latest updates with the hosted version, the IPFS-hosted version is a correct step towards decentralized and significantly more censorship-resistant.
The API: We will discuss the Polkadot.js API separately in later chapters when we dive deep into interacting with the Polkadot ecosystem from within our app.
Tool #2: Rust and Cargo – Our Development Backbone
Polkadot’s heart beats with Rust, a language famous for its safety and performance. Cargo is Rust’s package manager, helping us build and manage dependencies seamlessly. Note that, here, we outline bare minimum setup needed for Rust (the language) and Cargo (the build system and package manager for Rust). We assume a Unix-like system (e.g., Mac or Linux). For different operating systems (e.g., Windows), the steps might vary.
Open your terminal and run the following command to install Rust. This script automates the installation process for Rust and its associated tools.
Follow the interactive setup prompts in the terminal. More than often, the standard installation is enough.
Verify the installation by running this.
Hello, world!
).Setting Up a Local Node
While we will start with smart contract and application development, it is a good idea to dip our toes into node development at the earliest. This is primarily because, we can then use that Blockchain node for quick experimentation, deploying our smart contracts later etc.
To start on the boilerplate is fairly simple. We can start with the Substrate contract template.
Tip: Note that we used the substrate-contracts-node — purposefully ready-made primed for smart contract development with the substrate node template. We will explain what all these mean later, but we start with getting things up.
While we can build the node ourselves in our local system, it is easier (and much faster!) to just get the binary from the repo (https://github.com/paritytech/substrate-contracts-node/releases).
A caveat of this is that if your OS (e.g., Mac) is set with strict security control, the OS may not allow you to run the binary directly. You may change your settings to run (understanding the full ramifications of it, of course), or build the node from scratch in your local system first.
If possible, we recommend trying to build the node for fun — if nothing, it feels great to watch the terminal as it gets built (and frustrated if it fails!).
To build the node, we can simply use cargo. It will take some time depending on how powerful your local system is. Also, depending on your local system, it may not be successful at the first (or second!) if certain packages (e.g, protobuf) is missing.
Starting the Local Node: Starting the node is as simple as executing the binary (either extracted from the zip file of the release or the compiled binary).
Connecting polkadot.js to Our Local Node
Now comes the magic. We'll use polkadot.js to interact with the node we just spun up.
We can see the latest blocks, connect the Polkadot extension for self-managed accounts.
Some Troubleshooting Tips
Recap and What’s Next
Congratulations! We’ve just set up a powerhouse development environment. From polkadot.js to Rust, we’re ready to start tinkering with Polkadot’s ecosystem. In the next lesson, we’ll explore smart contracts with Ink! — a key building block for dApps.