While the whole community is keenly looking forward to the next phase of the Polkadot mainnet launch, Blaize’s team of blockchain architects want to share some knowledge using Polkadot Substrate for building parachains.
We have reviewed some of the most promising Polkadot startups in one of our previous articles. In this blog post, we would like to explain how to launch a project on Polkadot, develop a dApp similar to these examples, or implement a parachain. We will also describe how to make a cross-chain bridge between Polkadot and other existing solutions. And if you are interested in dApp development services, please contact us.
Why Do You Need to Develop a dApp on Polkadot?
Polkadot is a fast-growing ecosystem that will enable cross-chain communication within its parachains. Such interoperability and scale will bring blockchain technology to the next level and solve a number of problems (e.g. low TPS, high transaction fees, hard forks, etc.).
Ethereum DeFi is one of the biggest markets for dApp development. The growing number of Polkadot dApps heightens the problem of Ethereum chain operability as well as transaction costs. Polkadot’s scalable and interoperable environment makes it very attractive in terms of Ethereum DeFi’s future migration to Polkadot.
Read Also: How to fork a cryptocurrency
The claim has already proven its relevance through the successful implementation of new solutions like RIO Chain. It is built as a Polkadot parachain that provides ready-made tools to develop DeFi dApp on Polkadot. As an alternative, you can build Polkadot dApp on Substrate-based chains or deploy smart contracts to Moonbeam or Edgeware.
We will explain how to develop and launch your dApp project on Polkadot in the following sections of this article.
Read Also: In-House Vs Outsource Blockchain Development.
Initial integration with Polkadot
From our experience, we can define the following types of possible launch on Polkadot:
- Building a parachain for Polkadot
- Building dApp on Substrate-based blockchain
- Creating a cross-chain bridge (from your current solution to one of Polkadot’s parachains)
Those are generalized examples combining a long list of possibilities into three main groups. We would like to share more technical aspects regarding each type next.
Blaize’s team of blockchain developers has been studying the unique technical specifications of the Polkadot ecosystem for a few years. We are currently working on several projects to launch on the network in the near future. Follow Blaize news updates to see future case description in detail.
Building a parachain to Polkadot
Before considering this approach and starting parachain development, let’s define what a parachain is and why it is different from running an independent blockchain.
Polkadot provides a highly scalable and secure ecosystem of blockchains. Yet, those blockchains are actually parachains. The main difference between them lies in shared security.
Any created parachain has to be connected to the Relay Chain (the main chain of Polkadot). Along with this connection, the Relay chain will provide the parachain security and a guarantee of secure cross-chain communication (XCMP) between all connected parachains in the system. Thus, the Polkadot ecosystem ensures the desired interoperability and scalability of all chains together.
Polkadot Parachain Development
There is a claim that creating a Polkadot parachain requires a strong knowledge of Substrate. Substrate as well as Polkadot are written in the Rust language. Consequently, you can implement parachain development in Rust.
From another perspective, generally, you can implement a custom blockchain development in any language (C++, Go or Java). If a certain interface is respected you can connect it as a parachain.
Yet, in order to ease development, Polkadot provides PDKs (which stands for Parachain Development Kit). Currently, there are two functioning PDKs which are Substrate and Cumulus.
Parity Substrate is a cutting-edge solution that allows for building a complex blockchain architecture within a short period of time. This reduces Polkadot development time significantly from years to weeks. So we recommend using the ready-made Substrate framework for building a parachain instead of writing initial coding in Rust, Go, or others.
Previous working experience with Substrate will be a huge plus. Get to know more about the Substrate framework and its characteristics in Best Blockchain Platforms comparison.
The basic set of tools for Polkadot parachain development:
- Substrate 2.0.0.
- Polkadot source code
- WASM interpreter and compiler to WASM
- Rococo
The first step is to set up the latest version of the Substrate framework. The best way is to use Parity Knowledge Base. As soon as the environment is prepared, we can start to modify the live version of the parachain template code. The initial code can be taken from the Polkadot repository here.
Substrate technology contains all the necessary modules and frames for an independent chain development. But it does not have the required compatibility feature with Polkadot.
Therefore, as soon as the main chain architecture is done, you need to start using the Cumulus library. Cumulus will add the required parachain code while importing a Substrate-based chain to the library. Thus, it makes it compatible with the Polkadot environment.
In order to check a new-build parachain, we need a testnet examination. One of the major Polkadot testnets, Rococo, has been created to meet the specifications of parachains testing.
After testing you will need a parachain slot to deploy your chain and connect to the Relay chain. The project will need to acquire one of the parachains’ slots in the auction that will take place shortly. But take into account, you can test and deploy your parachain on Kusama (Polkadot cousin).
Develop a dApp on Polkadot
Claiming a breakthrough in operability and scalability Polkadot attracts a lot of minds eager to build dApps on Polkadot within its network. It is especially attractive for open finance developers seeking to create a full market of DeFi on Polkadot (read about DeFi derivatives).
The first thing you should know is that the Polkadot Relay chain itself does not support any Polkadot smart contract framework. However, the arbitrary state transitions inserted into parachains do offer such support. This technology will be released shortly and will allow for building dApps on a Polkadot parachain.
Read Also: How to Avoid Impermanent Loss and Front-running Problem in DeFi.
For now, it is recommended to use one of the existing technologies and prepare your future Polkadot dApp to be ready when the parachain starts.
Smart contracts are a core for any decentralized application development. The Polkadot system is very complex and tiered, but there are a few ways to deploy smart contracts on Polkadot:
- Develop smart contracts in any language compiled to WASM (Java, Go, etc.)
- Develop dApp using Substrate EVM pallet
- Develop dApp using Substrate Ink contracts pallet
We will use the third approach to provide an example of dApp development for smooth integration with a Polkadot parachain in the future.
Example of dApp development on Substrate-based chain
Due to wider adoption of Substrate and its growing demand, we would like to show the example of using Substrate FRAME for building a dApp for Polkadot.
The basic set of tools for (Polkadot) dApp development:
- Substrate 2.0.0.
- Rust
- !Ink
- WASM interpreter and compiler to WASM
Substrate FRAME is a code library storing ready-made modules (or otherwise pallets) to build your custom blockchain with Substrate. To create a decentralized app on top of it, one needs to combine chosen modules into the “runtime” of the framework.
In order to enable smart contract functionality we should add a _contracts pallet.
For customization, we can add all necessary imports and dependencies, develop on Polkadot custom traits within this pallet or even add more custom pallets and start the configuration.
After that, you can think of deploying Polkadot smart contracts for your dApp to the live environment. Currently, there are two leading solutions that offer smart contracts running via the Polkadot environment: Moonbeam and Edgeware.
Edgeware is a Substrate-based chain that will connect to the Relay Chain as one of the Polkadot parachains in the near future. It enables smart contracts on Polkadot to run with its further compilation to WASM. Edgeware is a perfect solution to try out the contracts made with the contracts’ pallet from the Substrate FRAME library.
In case you have chosen the Substrate EVM pallet, think of a Moonbeam smart contract solution. It uses an interoperable layer containing the current Ethereum toolset called Frontier. The Moonbeam platform will support all application contracts written for the EVM environment.
Read more detailed information about Moonbeam and Edgeware projects in Top Projects on Polkadot.
To underline, you can deploy smart contracts on Polkadot only using one of its parachains. Though you can build your custom dApp on your own Substrate-based node.
Nevertheless, consider trying any of the smart contract solutions for Polkadot detailed above. Read: Ethereum dApp Development Guide
Create a cross-chain bridge to the Polkadot ecosystem
Building a cross-chain bridge is the other way to connect to the Polkadot ecosystem. There are basically two options: create a bridge for your current solution, or provide bridge-as-a-service between two existing decentralized protocols.
From a technical point of view, a cross-chain bridge is an app for a token “transfer” between two blockchains. The transfer is made through smart contracts on both sides of the bridge and a decentralized network of independent validators.
The cross-chain bridge idea implies that tokens are moving (or transferring) between chains or protocols. But in fact, when a money transfer request occurs, the contract burns tokens on one chain and mints them on the other.
There is a feature when the contract locks tokens instead of burning them if the initial token contract does not provide a burning function. Those specifications might be hard to detect for a less experienced blockchain developer. Read how to find experienced blockchain developers to create a solid project.
In order to make any transaction, the contract needs a signature from a subset of validators that run the bridge. That is why the bridge is quite similar to the way a multisig contract functions. When a money transfer request goes to one of the contracts, the relayers (validators) ought to create a vote on this transaction and approve token minting on the opposite side of the bridge.
Read also: AMMs models
Building a bridge using Substrate
The Substrate framework provides a full collection of components and pallets for building bridges. The full documentation can be found here.
As an example, we will build a relay bridge from Ethereum to Polkadot. We decided to use !Ink because it is the primary language for smart contracts on Substrate. As an alternative, we may use Rust with no inconvenience.
Relay bridge components:
01 Smart contracts
As we have mentioned before, we should create smart contracts on both sides of the bridge.
02 Substrate pallets
For cross-chain bridge implementation, we can use the following Substrate pallets: syncing header pallet, arbitrary messages pallet, relayer pallet.
03 Validator program
One of the most important parts of this development is the validator program. This should take into account such parameters as the number of validators (relayers) and the established threshold for them. The threshold is the limit of required validators to approve the transaction.
For instance, in case there are five relayers for this bridge, and the threshold amount is three, the transaction will be approved after three confirmations occur with no need to wait for the rest.
The daily limit is another substantial element of the validator’s program development. By establishing this feature you can specify the exact amount of funds that can be passed to one side per day.
The example of validation method for approving cross-chain transactions:
04 Application interface (UI)
To interact with both sides of the bridge and the smart contracts in it, you will need a dApp. That is how the end-user will benefit from the bridge and “transfer” funds from one chain to another.
Thinking of creating a bridge? Contact Blaize experts to schedule a meeting to start development ASAP!
Existing Ethereum-based DeFi protocols should consider creating a cross-chain bridge to Polkadot. This type of development is faster than making a new dApp and has significant potential for possible interactions. You can create a bridge from the current solution to a Polkadot parachain as well as connect to existing Moonbeam contracts. Such projects as Akropolis, Chainsafe, and Snowfork have already presented similar cross-chain solutions.
Conclusion
In this article, we have shown how to build a parachain on Polkadot or use a Substrate-based chain to create a dApp. We have also reviewed the process of creating a cross-chain bridge between Ethereum and Polkadot and answered the questions of why and when it is applicable.
Polkadot is a fast-growing ecosystem that has a great impact on the blockchain community. After reading this post, you now know how you can join it and build your own dApp or parachain for Polkadot. We also invite you to familiarize yourself with our expertise in the development of NFT tokens and GameFi development.
Launch your project on Polkadot with Blaize!
FAQ
- What are the requirements to launch a project on Polkadot?
To launch a project on Polkadot, you need to have a clear concept, a skilled development team, knowledge of Polkadot’s ecosystem and tools, such as Substrate, and sufficient funding to cover development costs and potential parachain auction participation.
- What are the steps to follow to launch a project on Polkadot?
There’s no a certain list of the steps, but we recommend to consider the following:
- Define your project’s purpose and technical requirements
- Assemble a skilled team with expertise in Polkadot and Substrate
- Develop your project using the Substrate framework
- Optionally, participate in a parachain auction to secure a slot on the Polkadot network
- Deploy your project and promote it within the Polkadot community
- How can I connect to the Polkadot network and deploy my project?
To connect to the Polkadot network and deploy your project, follow these steps:
- Develop your project using the Substrate framework
- Set up a local or hosted node connected to the Polkadot network
- Use the Polkadot.js API to interact with the network and deploy your project
- What are the key features of Polkadot that make it a good platform for new projects?
Scalability: Polkadot’s multi-chain architecture allows parallel processing and high throughput
Interoperability: Seamless communication between various blockchains, including bridges to non-Polkadot chains
Customizability: The Substrate framework enables easy development and deployment of custom blockchains
Shared security: Parachains benefit from Polkadot’s pooled security, reducing individual project security overhead