What are bridges in blockchain and how do cross-chain swaps work?
There is a lot of innovation happening in the Crypto / DeFi space. While Ethereum is the dominant blockchain for DeFi (Decentralized Finance) economy there are also many other chains building and developing competitive DeFi systems today such as: Algorand, Avalanche, Cosmos, Polkadot, Tezos, Solana etc.
While these are building a parallel DeFi ecosystem to Ethereum there is also an increase in the number of new blockchains being launched. They are side-chains, layer two protocols, sharding or parachains or EVM (Ethereum Virtual Machine) compatible blockchain that are mainly designed to provide scaling solutions. Some examples are Arbitrum, BSC (Binance Smart Chain) and Matic (Polygon).
With a growing set of Layer 1 networks and Layer 2 side chain protocols the future of DeFi is cross-chain that will be bridging different networks and bringing DeFi to the masses.
So why bridge between blockchains? What are cross-chain bridges and how do cross-chain swaps work?
Bridging Blockchains
Cross-chain bridges are becoming an important piece of DeFi ecosystem due to the growing list of blockchains. All that growing list means the value continues to spread among blockchains.
Each blockchain is unique and each have their own features and functionalities. Not only that but most of them are developed in an isolated environments, and they operate under different consensus rules. As a result they have no way of communicating with other blockchains.
Now bridges cover the gaps between different ecosystems so that growth is not limited to one single chain. Not only they spread growth to other blockchains but they also ensures widespread scalability and unleash a new level of usability for DeFi apps and infrastructure thus increasing the value across ecosystems.
Consider a bridge in crypto like a bridge in the physical world. Bridges in real world simply connect two distinct locations and communities so that the people can travel back and forth and resources can be exchanged freely.
Likewise using bridges in blockchain users can easily transfer tokens and other crypto assets between two or more networks.
Cross-chain interoperability is the way to create maximum value for users. Also in order to ensure scalability and connectivity among the DeFi ecosystem the need to connect blockchains becomes critical.
So how token transfer happen between two different blockchains and how a Layer 1 and 2 can communicate each other?
This is where bridges come into play.
What are blockchain bridges? Cross-Chain bridge
What are cross chain bridges, and why are they important for DeFi? As Web 3 continues to expand bridges become more crucial as they open doors across the ecosystem.
A blockchain bridge also known as cross-chain bridge is a connection between blockchains that allows users to transfer tokens, assets and/or arbitrary data from one chain to another.
There are so many DeFi ecosystems currently such as Ethereum, Polkadot, Avalanche, Cosmos, Fantom, Polygon, Terra (Luna), Harmony, Near, Optimism and many others. Each of these platforms have different protocols, have different rules and governance models. Due to their distinct features many DeFi users simply want to move their digital assets from one chain to another. So that they can use dapps interchangeably and leverage other DeFi services more efficiently.
Even though each chain run under different consensus rules bridges provide an inter-communicative, interconnected link that enables communication and interaction between the two distinct networks.
Not only tokens but users and developers can move any type of data between blockchains including decentralized identifiers, smart contract calls and off-chain information such as price feeds of stock market via oracles.
Benefits of Bridges in DeFi
Bridges are proving to be more valuable in the DeFi ecosystem. Not only it benefits the end users but is also valuable for the entire cryptocurrency ecosystem.
- Bridges provide flexibility – It enables user to transfer assets and valuable data from one blockchain to another. This enables users to access the benefits of different blockchain technologies and they aren’t limited to the capabilities of one particular chain.
- Cross-chain collateral – Using cross chain bridge users can simply reap the rewards of all chains. One of the most popular scenario is Bitcoin users benefiting from the functionalities of DeFi on the Ethereum blockchain. Bitcoin on Ethereum becomes Wrapped Bitcoin (WBTC), an ERC20 token where native BTC holders can trade around the well-established DeFi ecosystem and reap the rewards.
- Interoperability between blockchains – Bridges not only provides interoperability between individual blockchains but also provides a connect between L1 main chain (parent blockchain) and L2 chain (child chain). This allows developers to implement and execute DApps across DeFi platforms (e.g: rollups built on Ethereum). This interoperability between blockchains simply increases the rate of mass adoption.
- Scalability – Bridges in DeFi greatly enhance the network scalability. Since it enables connection between the main chain and secondary chain it can distribute the transaction loads across their ecosystem. That too without giving up on the liquidity and the network effects. Allowing traffic between many blockchains and layers is beneficial during high transaction volumes especially when the main chain gets congested.
- Efficiency – Using Bridges users can move their assets from a non scalable blockchain to a high performance chain and take advantage of the low gas fees while still benefiting from the Ethereum’s smart contract capabilities. They can even conduct micro-transactions on chain quickly and without having to worry about high transaction costs. Ability to conduct fast, low cost transaction simply enhances the DeFi and DApp experience.
Now that we’ve understood the benefits of bridges in blockchain lets see how cross chain swaps work.
Cross-Chain Swaps – How do they work?
DeFi participants use cross chain bridges to achieve cross-chain swaps.
What are Cross-Chain Swaps? Cross chain swaps also sometimes called as atomic swaps that are performed when you want to move coins and tokens from one blockchain to another that runs on a completely different system. So how does it work?
First of all there are two types of cross-chain bridges: 1. Centralized cross chain bridges and 2. Decentralized trustless cross chain bridges.
Centralized bridges
Centralized cross chain bridge uses centralized system and they are based on a third party trust. During the early days people used the bridge solution offered by the exchanges where they can swap their assets between different blockchains.
For example even Today from your Binance account you can swap and transfer your Ethereum ERC20 to Solana chain, to BEP20 (Binance Smart Chain), ARC20 Avalanche chain, Polygon network and many other supported chains. Not only Binance but many exchanges do offer the possibility to swap tokens between blockchains.
These bridges are also called as wrapped bridges that issues pegged tokens matched one to one on either blockchain. One of the most popular trust based bridge scenario is the initiative that enables hodlers of Bitcoin to transfer their BTC as Wrapped Bitcoin (WBTC) to Ethereum blockchain. Once transferred they can leverage the benefits of DeFi on Ethereum.
In the centralized bridge, users deposit BTC into a partner wallet. It is basically a trusted centralized custodian wallet that stores your Bitcoin safely and mints equivalent wrapped BTC (WBTC) or tBTC tokens on the Ethereum network.
It basically locks up the BTC on Bitcoin and mints equivalent BTC tokens on Ethereum. When you want to transfer the BTC back to Bitcoin network the wrapped tokens on Ethereum will be locked or burned and locked BTC on Bitcoin will get unlocked for you.
The wrapped BTC on Ethereum network is an ERC20 token that you can use it as a collateral in a variety of Decentralized Finance (DeFi) protocols such as: Uniswap, Aave, Maker DAO, Compound, Synthetix, Curve, Sushiswap, Balancer, 0x Protocol and many others.
These centralized services that facilitate cross chain activity have some cons such as charge of high fee for transfers, need of KYC registration etc. But these days users no longer rely on these centralized services to perform token swaps.
There are many decentralized cross-chain bridges – A new type of protocol that made possible for users to transfer assets between blockchain without the need of centralized third party service. Now users can move their assets across different blockchains in an automatic and in a permission-less way.
Decentralized cross-chain bridges
While the centralized bridges are based on a third party trust; the decentralized or trustless cross chain bridges are based on a cryptographic mathematical trust.
Unlike CEX in a decentralized system users don’t have to sign up and there is no collection of user data either. Instead of putting trust in a centralized authority; users place their trust in the mathematical truth. In blockchain system the mathematical truth is achieved when the computer nodes or when a program reaches a common agreement (consensus) in accordance to the rule specified in the underlying blockchain’s codebase.
Decentralized cross chain bridges achieves cross chain swaps in a completely decentralized mechanism without the need of a middle man or an escrow. They do so with the help of smart contracts.
A cross-chain swap is a completely decentralized mechanism of exchanging tokens from one chain for non-native ones on the other chain. It is performed through special smart contracts – An application or a program that connects two different networks and perform the exchange of tokens automatically when specific conditions are met.
Here is how a cross chain swap works in a decentralized bridge:
How bridges work?
Most bridges in order to transfer asset between chains they lock up the assets on source chain and mint equivalent amount of wrapped assets on the destination chain.
When you initiate a transfer of assets from one blockchain to another using a bridge the assets are in fact not relocated or sent anywhere. Instead the transfer functionality is leveraged through a two step process and is all handled by the smart contract.
Let’s assume you want to move tokens from Chain A to Chain B. What bridges does is they lock up or freeze your asset temporarily on Chain A. Then mint equivalent amount of fresh tokens that will be unlocked for you on Chain B that is on the receiving blockchain. When you want to redeem the tokens that is when you wish to move original assets back from Chain B to the original chain (Chain A) the tokens which are minted on Chain B will be burned, and the original assets will get unlocked.
Assets on blockchain A will unlock only when the equivalent amount of minted tokens on blockchain B gets burned or locked again. This prevents users from using the assets on both blockchains at the same time.
The concept of cross chain interoperability and the transfer or tokens is carried with the aid of 2 way peg system; where the value of the token on either blockchain is same as it remains pegged to the value of original ones.
For example the value of 1 BTC on Bitcoin Network is always equal to 1WBTC on Ethereum Network. Not only their value is pegged. Also the total amount of circulating supply of tokens remains the same on both the chains but is split between the two chains.
Side Chain Bridges
Other than cross chain that connects two completely different networks there is also something called a sidechain bridge. A side chain bridge connects main chain (L1) that is parent blockchain to its child (L2). Because since both L1 and L2 operate under different rules, there is a need for bridge in order to communicate between the two networks.
When it comes to Layer 2 protocols / sidechain environment both bridges and chains benefit from each other. For example chains notify bridges about the balances and the bridges used that information to aid the transfer / withdrawal process.
Likewise chains also rely on bridges to accurately represent the assets on another network including: The record of deposits / withdrawals of tokens / NFTs and other digital assets that can cross over the bridge. This exchange of information is sent to a smart contract on the other blockchain, often via an oracle.
The smart contract is programmed in such a way that it requires proof that the necessary on-chain activity have originally take place in order for the bridge to lock/mint and to burn/unlock the assets on both the chain.
With this approach users are allowed to move any digital assets from one network to another without any third party assistance. This cross chain functionality connects blockchains and layer one protocols to bridge assets so that token holders can interact with DApps across the ecosystem.
As far as the need for enhancing interoperability between blockchains is concerned, cross-chain technology is one of the most effective solutions to facilitate the same.