The Hackett Group Announces Strategic Acquisition of Leading Gen AI Development Firm LeewayHertz
Select Page

All About Polkadot Bridges

all-about-polkadot-bridge
Listen to the article
What is Chainlink VRF

Decentralized finance is well-known for hassle-free money transfers without third-party intervention or bank transaction fees. But, when we talk about transferring tokens between two decentralized platforms that follow different consensus mechanisms the gas fees get exorbitant. The cross-chain transactions are processed at a cost of large gas fees incurred depending upon the difference in their consensus mechanisms.

To address the issue of high gas fees in cross-chain transactions, cross-chain bridges were created. These bridges are essential to induce growth across different blockchains, offering asset interoperability with high security and improved asset rendition.

With increased demand for transactions between blockchains functioning under varied consensus mechanisms, cross-chain bridges have gained immense importance. They help in improving communication between different peer-to-peer networks at a minimal cost. Along with reducing the gas cost, the cross-chain bridge also focuses on increasing the transaction speed, to improve the interaction with the crypto assets for a good user experience. It improves the potential of the existing crypto assets and gives high security and privacy.

Polkadot has various methods to facilitate interoperability and one of them is through its parachains. Although every blockchain is not a parachain, they still require a secure medium to communicate with other chains. This is where Polkadot bridges come in, to pave a way for exchanging crypto assets and transacting from one platform to another with a different consensus mechanism like Ethereum, Avalanche, Cardano, BSC.

The Polkadot network supports various bridging techniques like pallets, smart contracts and higher-order protocols. These techniques help bridge the connectivity gaps between the various blockchain ecosystems in a decentralized way for economic sovereignty. This article is a quick guide to the cross-chain bridges on the Polkadot network.

Let us now understand the concept of bridges first.

What are blockchain bridges?

Blockchain bridges are one of the most important technology for facilitating interoperability between multiple blockchain platforms, that have different consensus mechanisms, communities and governance models. A blockchain bridge eliminates this difference by providing a compatible solution for both blockchains for efficient interoperation. It helps in connecting two blockchain platforms that might not be parachains but want to communicate with each other. The communication between these blockchains includes crypto-asset transfers, token transfers and arbitrary data transfers. A blockchain bridge eliminates this difference by providing a compatible solution for both blockchains for efficient interoperation.

There are various blockchain bridge designs and these designs are divided into two basic categories: centralized/ trusted/ federated bridges and decentralized/trustless bridges. We will be focusing on decentralized trustless bridges in this article. Trustless bridges do not have any central authority for validating cross-chain communication. They rather work on the basis of mathematical codes in a decentralized and autonomous way.Blockchain bridges are one of the most important technology for facilitating interoperability between multiple blockchain platforms, that have different consensus mechanisms, communities and governance models. A blockchain bridge eliminates this difference by providing a compatible solution for both blockchains for efficient interoperation. It helps in connecting two blockchain platforms that might not be parachains but want to communicate with each other. The communication between these blockchains includes crypto-asset transfers, token transfers and arbitrary data transfers. A blockchain bridge eliminates this difference by providing a compatible solution for both blockchains for efficient interoperation.

There are various blockchain bridge designs and these designs are divided into two basic categories: centralized/ trusted/ federated bridges and decentralized/trustless bridges. We will be focusing on decentralized trustless bridges in this article. Trustless bridges do not have any central authority for validating cross-chain communication. They rather work on the basis of mathematical codes in a decentralized and autonomous way.

What is a Polkadot bridge?

Polkadot was formerly designed as the fundamental structure for implementing scalability, interoperability and security for cross-chain networking. It allowed various layer-1 parachains to communicate within one ecosystem. Polkadot has another interesting feature where it allows a parachain and any other non-parachain to communicate. It does so by implementing blockchain bridges. Because the Polkadot network was developed to reduce mediation in different P2P networks, blockchain bridges are preferred majorly for trustless cross-chain interaction.

Let us now unfold Polkadot bridging with an example. Think of a decentralized marketplace for an insurance agency. One way is to deploy customized parachain that will function as a marketplace for the traders of insurance. We will assume that Polkadot has an oracle parachain that brings external data on-chain along with an Internet of Things (IoT) parachain that collects all the data from off-chain IoT devices.

In a scenario where you have bought a flight delay insurance, the insurance policy can be created in a way that it will pay off if the oracle parachain confirms that there is a delay in the flight and the IoT parachain validates that you were at the airport as per the specified time. If the insurance parachain receives a signal from the oracle and the IoT parachains, then it could utilize a blockchain bridge to initiate a transaction using a cryptocurrency, from the insurance company’s account to the policy owner’s. That is how bridging facilitates interoperability.

Now that we have understood how bridging functions in the case of parachains and non-parachains, there is a single framework that builds both sorts of chains. This framework is known as the substrate framework. Substrate-based parachains are connected and secured by Polkadot and Kusama Relay chain, so they gain inherent interoperability with other parachains. However, the substrate-based solo chains, as well as non-substrate based independent chains like Ethereum, can connect and interact with the parachains via blockchain bridges.

For the substrate-based chains’ connectivity, Polkadot’s Parity team has worked on building a generic bridge. This bridge will consist of a variety of components that in unity will enable cross-chain and bi-directional interaction between a solo substrate-based chain and a parachain, or between two solo substrate-based chains.

Web3 Foundation Grants have supported the development of various bridges. Let us explore some of these blockchain bridges in the next section.

What kinds of bridges are being developed on the Polkadot ecosystem by different networks?

Details of the Polkadot blockchain bridges that are supported by the Web3 Foundation Grants are as follows:

Interlay

The Interlay platform has built a trustless bridge between Bitcoin and Polkadot. It is currently functioning at the beta testnet phase. The bridge will help users mint assets backed up by Bitcoin for a ratio of 1:1 on the Polkadot platform. These minted assets will then be known as the PolkaBTC.

PolkaBTC can be utilized with any app or parachain inside the Polkadot ecosystem in the form of a native asset. PolkaBTC helps unlock the BTC liquidity for Polkadot’s decentralized finance. But under all this process, the PolkaBTC uses the XCLAIM protocol, which transforms the bridge into a trustless, permission-less and censorship-resistant bridging medium.

Snowfork

Snowfork is another platform that has built a general-purpose bridge between the Ethereum blockchain and the Polkadot. This bridge will help transfer the ETH, ERC20 assets and the arbitrary data from the Ethereum chain to the Polkadot chain. Along with the asset transfers, the general-purpose bridge built by the Snowfork also enables cross-chain smart contracts calls.

Darwinia

Darwinia is a network known as the cross-chain bridge hub. It has built a permissionless and noncustodial bridging protocol that features low cost and efficient decentralization of the cross-chain tokens. Darwinia’s bridging protocol also focuses on other cross-chain exchanges like crypto-asset transfers. This bridge integrates technologies like optimistic verification mechanisms.

Centrifuge

Centrifuge in collaboration with ChainSafe built a bridge called the ChainBridge that is modular, asset-agnostic, and multi-directional in nature. The ChainBridge allows the Centrifuge platform to transfer fungible and non-fungible tokens between chains. ChainBridge being open-source in nature helps other teams on the platform to build bridges to eliminate the gap between their projects.

ChainX

ChainX is a crypto assets exchange platform that intends to build bridges to several networks and has implemented a bridge between BTC to a substrate based chain. As per the bridge design of the ChainX, the bridge is used by the validators who are staked in the PoS consensus of the ChainX and they also control a BTC multi-sig wallet.

Bitfrost

Bitfrost is another platform that has developed a bridge for the EOS networks. This bridge enables cross-chain asset transfers in a trustless manner by implementing light nodes on-chain along with the merkle tree verification.

Now that we are familiar with the different kinds of bridges being developed on the Polkadot ecosystem, it’s time that we explore the fundamental methods of blockchain bridging in the next section

Leverage Polkadot's Interoperability via custom parachains

Polkadot Blockchain Development Company

What are the various blockchains bridging methods?

Blockchain interoperability is backed up by the unique bridging technology. Bridging technology is specifically integrated with the Polkadot platform, as it makes the Polkadot ecosystem compatible with the other blockchain networks such as Cardano, XDC, Ethereum, and many others.

There are some specific methods to build a Polkadot bridge that is decentralized and trustless in nature as mentioned below:

Pallets for bridging

For the substrate based-chains, there are bridge pallets for bridging the cross-chain communication gap. For instance, Kusama \<\> Polkadot bridge, as both the networks are parachains and both of them use a substrate.

A substrate pellet is used to receive messages on the Polkadot ecosystem from a non-parachain network. The substrate example can then be implemented on the Polkadot either in the form of system-level parachain or in the form of a parachain operated by a community.

In the case of independent non-substrate chains, bridging contracts are deployed to bridge the gap in cross-chain interaction as explained in the next section.

Smart contracts

If a particular chain is not functioning on a substrate, then use the smart contracts on the blockchain that is not on the substrate, to bridge the gap. For instance, the Ethereum mainnet has a bridging smart contract that will initiate ETH transactions depending on the Cross-chain Message Passing (XCMP) messages received.

With blockchain platforms and its Turing-complete smart contract languages, Polkadot can be effectively bridged with any other blockchain that has the smart contract capability. For instance, Ethereum’s Parity bridge consists of two smart contracts, each one being deployed on respective blockchains, that permits for transferring values on cross-chains. Initially, the Parity bridge’s PoC connects the side and the main Ethereum chains. ETH deposited in the contract of the main chain generates a balance in the denomination of the ERC-20 tokens on the Ethereum sidechain. In an opposite way, the ERC-20 tokens deposited back in the contract of the side chain can free up ETH on the main chain.

Higher-order protocols

Higher-order protocols, for instance, XCLAIM, can be utilized to bridge in case of no other options of bridging. XCLAIM specifically needs any swappable asset to be backed using collateral of relatively higher value than that of the swappable assets.

An example of a network that is best for higher-order protocols is Bitcoin since it is not capable of smart contracts and is a non-substrate network.

There are also three specific ways in which the Polkadot and Substrate chains are bridged to the Ethereum chain as given below:

  • Substrate EVM Module
  • Polkadot<-> Ethereum Public Bridge
  • Substrate<->Parity Ethereum (Openethereum) Bridge

Now that we are familiar with the methods of bridging, let us understand the mechanism of installing and running Parity bridges in the next section.

How to install and run a Parity bridge?

There is a list of components for building Parity bridges as given below:

  • Substrate pallets to sync the headers
  • Passing arbitrary messages
  • Libraries to build relayers for-chain communication
  • Three bridge nodes to run the test networks

Let us now understand the process of installing and running a Parity bridge.

Installation

To install and run the Parity bridge we will require both, a stable and nightly Rust. Nightly Rust is required to develop the Web Assembly (WASM) runtime for the bridge nodes. To configure the WASM support, enter the following command,

rustup install nightly
rustup target add wasm32-unknown-unknown –toolchain nightly

After the configuration, build and test the repo as the following,

git clone  https://github.com/paritytech/parity-bridges-common.git
cd parity-bridges-common
cargo build --all
cargo test --all

We can also create the repo using the Parity CI Docker image, by entering the following command,

docker pull paritytech/bridges-ci:production
mkdir ~/cache
chown 1000:1000 ~/cache #processes in the container runs as "nonroot" user with UID 1000
docker run --rm -it -w /shellhere/parity-bridges-common 
-v /home/$(whoami)/cache/:/cache/    
-v "$(pwd)":/shellhere/parity-bridges-common 
-e CARGO_HOME=/cache/cargo/ 
-e SCCACHE_DIR=/cache/sccache/ 
-e CARGO_TARGET_DIR=/cache/target/  paritytech/bridges-ci:production cargo build --all
#artifacts can be found in ~/cache/target

High-Level Architecture

This repo contains the support for bridging the gap between two foreign chains via a combination of the Substrate pallets and relayers. A bridge chain in a high-level architecture follows the consensus of an independent foreign chain. For instance, take a glance at the figure given below. In this figure, we intend to bridge two substrate chains, X and Y respectively.

bridge-relay

The X chain should be able to receive Y headers and validate their integrity. It will do so by utilizing a runtime module made to monitor the GRANDPA block finality. As both the blockchains cannot communicate directly, they will require an external service, known as the relayer, to interact. The relayer will subscribe to the X chain headers with the help of the Remote Procedure Call (RPC) and will submit these headers to the Y chain for validation.

Project Layout

Following is an overview of how the project will be laid out. The main parts are the nodes (the actual blockchain), the modules which are required to build the blockchain’s runtime and the relays which will pass on messages between two chains.

├── bin             // Node and Runtime for the various Substrate chains
│  └── ...
├── deployments     // Useful tools for deploying test networks
│  └──  ...
├── diagrams        // Pretty pictures of the project architecture
│  └──  ...
├── modules         // Substrate Runtime Modules (a.k.a Pallets)
│  ├── grandpa      // On-Chain GRANDPA Light Client
│  ├── messages     // Cross Chain Message Passing
│  ├── dispatch     // Target Chain Message Execution
│  └──  ...
├── primitives      // Code shared between modules, runtimes, and relays
│  └──  ...
├── relays          // Application for sending headers and messages between chains
│  └──  ...
└── scripts         // Useful development and maintenance scripts

Running the bridge

We will connect the bridge relay node with the RPC interface of the nodes on every side of the bridge.
Bridges are run in the two following ways,

  • Creating and running from the source
  • Running a docker-compose setup

Using the source

Begin by building the nodes and the relay by using the following command:

In parity-bridges-common folder
cargo build -p x-bridge-node
cargo build -p y-bridge-node
cargo build -p substrate-relay

Running the dev network

Launch the dev network to explain how to relay communication between two substrate chains (X and Y chains as given in the image above)

To launch the dev network, we will use two nodes, two relayers for relaying the headers and two more relayers which will relay the messages.

Running from local scripts

First run the two substrate nodes using the following commands,

#  In ‘parity-bridges-common’ folder

./deployments/local-scripts/run-x-node.sh
./deployments/local-scripts/run-y-node.sh

After this run the header relayers,

./deployments/local-scripts/relay-y-to-x.sh
./deployments/local-scripts/relay-x-to-y.sh

This is when we will see the relayer giving headers from the Y substrate chain to the X substrate chain.

# Header Relayer Logs

[y_to_x_Sync] [date] DEBUG bridge Going to submit finality proof of y header #147 to x
[...] [date] INFO bridge Synced 147 of 147 headers
[...] [date] DEBUG bridge Going to submit finality proof of y header #148 to x
[...] [date] INFO bridge Synced 148 of 149 headers

Lastly, run the message relayers,

./deployments/local-scripts/relay-messages-y-to-x.sh
./deployments/local-scripts/relay-messages-x-to-y.sh

Conclusion

With the constant evolution of the DeFi sector, cross-chain bridges have surfaced as the most preferred mode of trading and transacting as compared to the traditional exchanges. They provide interoperability and consensual integration of decentralized applications to support various blockchains and investors, addressing the issue of capital flow by reducing transaction costs for the users. Bridges, thus compensate for the gaps between ecosystems so that the communication between traders and growth of trading is not limited to a solo substrate chain or a parachain.

For more guidance related to bridging between the Polkadot ecosystem and other decentralized networks, connect with our blockchain experts!

Listen to the article
What is Chainlink VRF

Author’s Bio

Akash Takyar
Akash Takyar
CEO LeewayHertz
Akash Takyar is the founder and CEO of LeewayHertz. With a proven track record of conceptualizing and architecting 100+ user-centric and scalable solutions for startups and enterprises, he brings a deep understanding of both technical and user experience aspects.
Akash's ability to build enterprise-grade technology solutions has garnered the trust of over 30 Fortune 500 companies, including Siemens, 3M, P&G, and Hershey's. Akash is an early adopter of new technology, a passionate technology enthusiast, and an investor in AI and IoT startups.

Start a conversation by filling the form

Once you let us know your requirement, our technical expert will schedule a call and discuss your idea in detail post sign of an NDA.
All information will be kept confidential.

Insights

Follow Us