DEV Community

Cover image for Polkadot: create your first Rust Substrate smart contract, upload it and interact with it πŸš€ [Video]
Nick Shulhin
Nick Shulhin

Posted on

Polkadot: create your first Rust Substrate smart contract, upload it and interact with it πŸš€ [Video]

Intro. Duction.

It has been a while I published a new post on dev.to, but this time it is a comeback + crypto!

Hold tight, because it may be intense.

I prepared this post since was a bit struggling to find a good end-to-end process of creating a DApp on Polkadot/Substrate, therefore maybe it will be of a help to someone. Polkadot/Substrate is still pretty much new.

Polkadot is a 3.0 blockchain which aims to resolve lots of issues from past projects such as Bitcoin and Ethereum 1.0.

But truly speaking, Polkadot is not a rival for other blockchains, it is more like an infrastructure which connects different blockchains a.k.a "cities" together and aims to create a network bridge among them.

Why should you care?

I discovered Polkadot when was frustrated using Solidity on Ethereum and exponentially high transaction fees. When suddenly Polkadot came into view with !ink(contract framework) smart contracts which can be written in Rust (love!) and crazy system of parachains and staking and... and... many more to come.

Why it will be beneficial for you no matter what?

Firstly you will start learning Rust which is absolutely fantastic language, as well as prepare yourself for the new generation of blockchains such as Polkadot. Polkadot has its parachains to be rolled out later this year, so it is a really good opportunity to prepare yourself.

Enough of this, let's go!


Part 1: Create your first !ink Substrate Smart Contract, build and deploy!

We are kicking off with my home-made YouTube tutorial which describes the process of creating your first !ink Substrate Rust smart contract project + using an NFT like project for those who are interested in Ethereum-like concepts:

Part 1

Links to bootstrap you for the video tutorial (especially go through !ink setup to have your Rust installed as well as Substrate framework):

NFT contract project: https://github.com/polk4-net/substrate-nft

!ink tutorial and setup: https://substrate.dev/substrate-contracts-workshop/#/

Canvas UI: https://paritytech.github.io/canvas-ui/#/upload

I mention using my own Canvas node at wss://canvas.polk4.net, however feel free to use your own local node or Parity official test nets to deploy your contracts.

Any problems? Drop me a message in comments!


Part 2: Use React and Polkadot.js to interact with your deployed smart contract!

Part 2

This is a very exciting section since you will go through how to interact with a sample "flipper" project using React.

Links to help you:

More on PolkadotJS API:
https://polkadot.js.org/docs/api-contract/start/contract.tx

Flipper-app React project:
https://github.com/polk4-net/flipper-app

Parity Canvas UI:
https://paritytech.github.io/canvas-ui/#/

In a nutshell I uploaded a GitHub React project which has everything you need to connect to your Polkadot.js extension wallet, choose account and send RPC requests and sign transactions which mutate the blockchain. Again, use either your local Canvas node or anything else.

From now on you have all building blocks to start experimenting with Polkadot build on testnet until... it launches parachains fully either on Kusama(its test network/canary) or in production on Polkadot net itself.


Thanks for reading, if you are stuck - drop a comment below.

Nick

Top comments (0)