Polkadot smart contract network

Polkadot has solved the interoperability problem, one of the biggest challenges for blockchain development. It is a vibrant ecosystem bridged to external blockchains. Using this protocol, businesses can even access databases in the real world. Learn how it works in our ultimate guide.

No ordinary platform

Polkadot was conceived by Gavin Wood, who also founded Ethereum. His brainchild appeared in May 2020 and was quick to gain momentum. As of May 6, 2022, the native token DOT is the 13th cryptocurrency by market cap (just under $17 billion).

Polkadot’s philosophy centers on interoperability. As the next-generation protocol, it is a diverse ecosystem of advanced layer-1 blockchains. They are called parachains, as all transactions are processed in parallel.

Conventional Transaction Processing vs. Polkadot. Source: Polkadot.network
Conventional Transaction Processing vs. Polkadot. Source: Polkadot.network

This protocol is dramatically different from siloed systems, which leave no window for external communication. Building on the legacy approach, Wood envisioned a massive nexus of blockchains that are now intertwined via XCM. Not only do they communicate – they also share security mechanisms. Here are five key features of this architecture:

  1. Connecting blockchains to each other
  2. Allowing users to develop new chains with ease using the Substrate SDK
  3. Hosting blockchains, securing them, and handling transactions
  4. Allowing parachain-based Dapps to interact with other parachains
  5. Bridging internal blockchains to external ones, such as Ethereum and Bitcoin

Polkadot token (DOT)

Polkadot’s native currency achieved its all-time high of $54.98 on November 4, 2021. Since then, the token has lost over 70% of its value. Currently, DOT is worth $14.44.

DOT Price Chart. Source: Coingecko
DOT Price Chart. Source: Coingecko

Within the network, DOT is a dual-purpose token. It is used for:

  • governance (allowing holders to have a say in the future of the protocol);
  • staking (enabling transaction verification and minting of more DOT).

Elements of Polkadot ecosystem

This is not the only model built on connections, but it offers significant benefits to creators of self-executing contracts. They take advantage of robust security, scalability, and smooth upgrades.

Transactions are speedy and scalable. As developers rely on a well-established system with its own audits, they pay lower gas fees compared to Ethereum.  As a result, they can devote more of their time and energy to the project at hand. So, how is Polkadot structured?

Key Elements of the Polkadot Network. Source: Polkadot.network
Key Elements of the Polkadot Network. Source: Polkadot.network

Relay chain

For most projects, an individual blockchain lacks functionality without connection to a larger community. Failure to provide safe and efficient liaison with additional infrastructure has spelled the doom of many blockchains.

Polkadot’s core is a hub. This blockchain is designed to link up to smaller ones, facilitate communication between them, and provide other benefits.

Parachains

These are parallel chains with their own runtime logic. They use shared security and the cross-chain messaging of the Relay Chain. Highly flexible and customizable, they are also rather demanding in terms of building and maintenance.

Parathreads

As an economical variation of a parachain, a parathread provides the same advantages but requires fewer resources. It is cheaper to secure. Instead of producing a block at every block of the Relay Chain in a specific slot, parathreads produce a block only when they need to.

Bridges

Aside from relaying data between its parachains, Polkadot also communicates with external networks. By means of bridges, it can interact with Ethereum, Bitcoin, and other ecosystems, giving creators more choice. Instead of seeking out a blockchain with the best connections, they can access a vast network.

Therefore, instead of pitting Polkadot against Ethereum, this architecture supports a win-win scenario. Apart from competing for an audience, it promotes collaboration and brings value to users and developers on both sides.

Example of Bridging in a DeFi Insurance Market Involving IoT Devices. Source: Polkadot.network
Example of Bridging in a DeFi Insurance Market Involving IoT Devices. Source: Polkadot.network

Parachain auctions and crowdloans

After being in the works for years, parachains were finally deployed on the mainnet in late 2021. In the initial parachain auction, Acala became the first protocol to secure a slot. This was a landmark event for the network.

To enter parachain auctions, projects must bid DOT tokens, which is rather costly. Some contenders resort to the cheaper alternative – crowdloans. This mechanism lets supporters lock their tokens and get a reward from the team in return. Typically, it takes the form of interest in DOT. Many major exchanges, including Binance, support the Polkadot crowdloans.

Consensus mechanisms

Nomination and selection of validators occur through a subtype of Proof-of-Stake (PoS) – Nominated Proof of Stake (NPoS). According to a recent study, this protocol is the most eco-friendly variation of PoS.

Comparison of Polkadot's Electricity Consumption to Other PoS Blockchains. Source: Energy Efficiency and Carbon Footprint of PoS Blockchain Protocols
Comparison of Polkadot's Electricity Consumption to Other PoS Blockchains. Source: Energy Efficiency and Carbon Footprint of PoS Blockchain Protocols

Participants (nodes) are divided into three categories. Working in unison, they maintain the integrity of the network.

Validators

These nodes are the most powerful and multifaceted. Aside from upholding consensus, they validate and produce new blocks on the Relay Chain. Through staking of DOT, they secure the network. Validators also verify specialized proofs from collator nodes (see below).

Nominators

These nodes mostly deal with security. They vote for reliable validators based on track record and stake DOT as an incentive. In return, they get a share of validator node rewards. When nodes misbehave, their voters are penalized – a portion of their stake is slashed.

Collators

These are full maintenance nodes. They gather parachain transactions and generate progress reports for validators (state transition proofs). Each collator needs two full nodes –  for the base platform and their parachain – to have enough data to author new blocks, collate transactions, and execute them. They deliver unsealed blocks to validators and transmit messages to and from other parachains.

Consensus Roles on Polkadot. Source: Polkadot.network
Consensus Roles on Polkadot. Source: Polkadot.network

GRANDPA consensus algorithm

The GHOST-based Recursive Ancestor Deriving Prefix Agreement makes the system more resilient and secure. Transactions are finalized more quickly thanks to agreement on chains rather than blocks.

Governance logic

Proposals may come from two arms of governance: the council (which also relays proposals from the technical committee) and the community. In normal conditions, the voting cycle lasts for 28 days and involves only one suggestion.

Getting to the proposing referenda requires the biggest weight of supporting tokens. Alternation is also mandatory: after each community-submitted proposal comes a council-submitted one.

Submitting of Proposals on Polkadot. Source: Medium.com
Submitting of Proposals on Polkadot. Source: Medium.com

Why on-chain upgrades beat hard forks

In conventional blockchain systems, updates require hard forks. This time-consuming method results in dual transaction histories, putting the integrity of the community at risk. From the very beginning, Polkadot strayed away from this model. Upgrades are performed within the chain to reduce three types of risk:

  • Splitting off the community
  • Overwhelming amount of administrative cleanup
  • Undesirable volatility of the token

Integrate via Substrate

Substrate is a powerful framework for building new blockchains and attaching them to the Relay Chain. It provides enhanced convenience and ease thanks to the use of the protocol connection points. Teams appreciate these benefits:

  • The opportunity to shift the focus from infrastructure essentials to the added value of the project
  • The opportunity to build blockchains from the ground up without significant prior experience

How to write smart contracts on Polkadot

The Relay Chain does not support smart contracts – it merely coordinates the parachains hosting them. Although deployment procedures vary, their logic is the same.

  • Creating a contract requires sending a transaction
  • Initialization and storage are provided for a fee

Polkadot supports contracts created on Ethereum, but it also has its own SDK. As a result, two development paths are possible:

Frontier EVM contracts

The Frontier tools enable EVM contracts to run on Substrate-based chains natively. This involves the shared RPC/API interface.

Substrate contracts

The native SDK supports a multi-chain future. A blockchain use case does not take long to develop, and it can be optimized for enhanced usability.

Dapps on Polkadot

Polkadot supports a wide spectrum of languages (Rust, C++, Haskell, Java, Python, and more) for Web 3.0 solutions and Dapps. Its ecosystem includes a range of SDKs (software development kits) and PDKs (Parachain development kits), along with a testnet. There are three ways to deploy an application:

  • as a smart contract on an existing parachain
  • as a new parachain
  • as a new parathread

Both parachains and parathreads require the same tools and give lower-level control of the app logic. The main argument in favor of parachains is more space, the opportunity to create monetary systems and other aspects from scratch. Execution of complex logic is highly efficient, while governance is more flexible and allows smoother upgrades than hard forks.

Parachains vs. smart contracts

Compared to smart contracts, parachains have benefits and drawbacks. Developers can build and execute intricate runtime logic at lower cost. The flip side is the absence of an obligatory gas metering system. This makes parachains susceptible to infinite loop bugs – the situation when the network consumes all the gas available for the transaction and then throws an exception.

In smart contracts, infinite loops are prevented by design. To reduce this risk for parachains, Polkadot uses a weight system implemented in Substrate. For developers, this translates into more laborious benchmark performance. Furthermore, smart contracts offer:

  • faster development
  • easier deployment
  • cheaper maintenance
  • stricter resource control

On the downside, smart contracts do not allow customization. They aren’t scalable and do not include native chain features. Some of the benefits also pale compared to parathreads, as those are also easier to deploy and cheaper to maintain than parachains. This is why, according to the Polkadot team, some projects use a combination of parachain, parathread, and smart contract.

Some of the projects on the protocol focus on its core capabilities. Others leverage the parachain power to offer unique products and services. In the developer-oriented segment, most smart contract platforms emphasize interoperability and EVM compatibility. Here are some of the most notable projects so far.

  • Karura Network (Acala) – a DeFi hub for financial applications. This all-in-one EVM-compatible network supports borrowing, lending, staking, and the aUSD stablecoin.
  • Moonriver (Moonbeam) – an EVM-compatible smart contract platform for building natively interoperable blockchain apps with limited contract modifications.
  • Khala (Phala) Network – a cloud computing service for preserving privacy on blockchains in Web 3.0. Its users get the best of three worlds: a secure environment with high computing power and flexibility.
aUSD Is a Defacto Stablecoin of Polkadot. Source: Acala.Network
aUSD Is a Defacto Stablecoin of Polkadot. Source: Acala.Network

To sum up: Polkadot as smart contract platform

This next-generation model allows separate blockchains to work together while transactions are processed in parallel. It offers many benefits for smart contract builders: shared security, high agility, smooth upgrades, modest fees, and a lower carbon footprint. Instead of using the existing chains for Dapps, they can build their own.