I recently joined the season 2 cohort of the Raid Guild DAO and as part of that experience had to pledge 1 wxDAI to obtain shares in the cohort DAO. Simple, I thought, just swap some ETH to DAI, bridge that to xDAI and then wrap it to wxDAI.
I forgot about transaction fees. Swapping 3$ worth of ETH to DAI would have cost me ~32$ worth of ETH. Pretty outrageous if you ask me. This got me thinking and I found some Matic/Polygon I bought a while ago, swapped that to DAI and bridged to xDAI for fees totalling less than a couple of cents. Low transaction fees feel great, they make you want to use a system like Packy describes it for Solana:
You don’t need to think twice about doing anything because it moves so quickly and costs so little. That’s the point. It feels like using the internet.
Low transaction fees are great, but every chain has their reason for implementing the way they did and Ethereum / Bitcoin have one that justifies its high transaction fees.
Vitalik calls it the scalability trilemma (see image below); some chains will sacrifice security and/or decentralisation for scalability. So if my transaction on Polygon goes through quickly and costs little, this means fewer validators will be validating transactions (less decentralised) and/or the network will be overall smaller and thus more vulnerable to a 51% attack.
Every blockchain has to decide where it wants to play and there will probably be different chains for different use cases. In 10 years Defi won’t be running on just one chain, but will consist of many different chains, each with their own pros and cons. These chains of course will be connected, like Polygon is connected to Ethereum and Ethereum is to xDAI. The connection is called a bridge and many of them have already been built.
This great overview by Larry0x shows a bunch of different L1 chains, L2 solutions and side chains and how they are connected to each other. The image misses a lot of different chains and bridges, but I think it’s still a good overview of the most important ones and how the ecosystem could evolve. Let’s briefly look at the different types of chains, how they connect and then get into how tokens flow.
Most bridges work like this: Tokens on Chain A get locked up and an equivalent amount get’s minted on Chain B. Moving tokens back to Chain A burns tokens on Chain B and unlocks them on Chain A. The magic happens in the communication between chains and James Prestwich explains it quite well.
Different chains and different layers can’t simply post transactions to each other, so there needs to be some logic implemented in between. Let’s go through some of the connections of the diagram above and look at how this — in between connection — actually works.
The EVM Union, from the image above, among others, shows Polygon and Optimistic connected to Ethereum. Polygon has two different chain offerings, but one of them is a sidechain, Optimistic is a layer 2 optimistic rollup solution.
Typically a sidechain is described as a chain with a separate consensus mechanism that is connected to a main chain via a bridge and is compatible with the main chain. In the case of Polygon’s sidechain this means that it has its own validators, staking mechanism and a token. A bridge moves tokens between main and sidechain. Additionally Polygon can run an Ethereum Virtual Machine, which makes it compatible with the main chain. Someone deploying an app will hardly notice any difference as compared to the main chain.
Let’s take my scenario of moving some DAI to xDAI. DAI is an ERC20 token on the main Ethereum chain and xDAI is the token of xDAIs sidechain. The two chains are connected via bridges. Bridges are smart contracts on both chains that connect to each other. To move tokens between chains, xDAI will need to be minted on the sidechain and DAI locked up in the contract on the main chain. To return DAI, xDAI will need to be burned on the side chain to unlock DAI on the main chain. The whole process is controlled by the validators of the sidechain, who have access to both contracts and can sign transactions — given there is a majority.
This is a simple solution that improves scalability. The downside is the reduced security and decentralisation as your funds are secured by the validators of the side chain and not the main chain.
Layer 2 Rollup Bridges
A layer 2 solution uses the layer 1 consensus mechanism, Optimistic, from the map above, is layer 2 to Ethereum and will thus be secured by Ethereum miners/validators. Layer 2 scales by allowing computation to happen off chain, but summarising transaction data back on-chain. There are multiple ways this can be done, rollups are just one possible option — Vitalik goes into more detail.
The bridge between layer 1 and layer 2 is slightly different to that of a sidechain. Funds will be deposited into a smart contract, secured by the main chain. The smart contract will map your funds onto layer 2 (into a merkle tree), but you keep control of your funds. Even if layer 2 stops running, you would still have access to the deposited funds in the smart contract.
To deposit ETH or other ERC20 tokens to layer 2, the wallet needs to be activated for layer 2. On layer 2 you then have the exact same native token that you have locked up on layer 1. Mainnet applications can migrate to layer 2 and more and more are doing so, allowing you to use the same app and the same token with much lower transaction fees but the security of mainnet.
Moving some ETH to layer 2 involves activating layer 2 and depositing funds into a smart contract. These funds will then be represented off chain in a merkle tree (still as ETH), which keeps track of all transactions and sends a proof of these transactions back to the main chain, where the balances are settled once withdrawn back to layer 1.
This is a pretty safe way to scale as you keep control of your assets. The more advanced technology, compared to sidechain, means a bunch of things are still under development.
Layer 1 to Layer 1 — Wormhole
Most of the other bridges on the diagram are layer 1 to layer 1 bridges. This includes Thorchain’s Bifröst, the Inter Blockchain Communication (IBC) and the Wormhole. Let’s start with Terra to Ethereum or Solana, which are all connected by the Wormhole.
Similar to layer 2 bridges, the Wormhole is not a blockchain network on its own. Instead it relies on the consensus of the chains it connects to. It uses Guardians, cross chain oracles, to certify token handling on the chains that it bridges. Guardians are validators with a proven track record and aligned incentives — via staking in the root chain (Solana).
When moving tokens from Ethereum to Solana, Guardians watch the Ethereum logs for a confirmation on the lock up ERC20 tokens. If a ⅔ majority of Guardians confirm the event by signing it, the minting of tokens on Solana will be triggered by the Wormhole Contract.
The process works similarly when transferring to or from Terra.
Transferring from Solana to Ethereum, locks up funds in a Solana smart contract and once Guardians have confirmed this lock up, they will sign the minting transaction on Ethereum. The user will receive the minted token into the wallet provided (try it out here).
Wormhole is a simple and easy way to connect chains, but the fact that multisig and validators from one chain are used makes it less secure than other options (IBC).
Layer 1 to layer 1 — Inter Blockchain Communication
The Inter Blockchain Communication (IBC) is part of the Cosmos SDK — The world’s most used framework for building blockchains. Among the blockchains built on Cosmos are Terra, Avalanche, Thorchain and many others. Building on Cosmos allows easy access to the IBC — but the IBC is also available for implementation outside of the Cosmos ecosystem. IBC is more of an infrastructure component that can be used to build applications that communicate between chains — token transfers being just one possible use case.
This guide does a great job explaining the details of how IBC works. The magic happens with a relayer role that monitors the other chains activities and stores a relay of the other chains block headers. Assuming that chain A trusts chain B’s consensus mechanism, it can now retain proof of funds deposited and locked and can thus unlock/mint funds on the other side.
The diagram shows a simplified version of connecting two chains within the Cosmos ecosystem. Connecting to chains outside the ecosystem is more complicated and requires additional development on the relay client side.
Moving funds from one chain to another will lock the funds in a smart contract on chain A. The relayer of chain B, will track this event via chain A’s block headers. Chain B’s smart contract will then trigger minting of tokens.
Compared to sidechains and the wormhole, IBC’s relayer implementation presents a more secure option as chains rely only on their own consensus.
Layer 1 to layer 1 — Thorchain
Thorchain is more than just a bridge, it is a decentralised exchange. As such it allows swapping of tokens, but instead of only doing swaps on one chain, like Uniswap, it allows swaps across chains. Thorchain achieves this by using a similar approach to the Wormhole. Instead of a multisig smart contract that locks/unlocks funds, Thorchain uses a threshold signature scheme (TSS) across validators to sign transactions. TSS works with cryptography instead of a smart contract and thus allows it to interact with chains like Bitcoin.
Thorchain validators (Thornodes) run a node for all chains they can interact with, so if a Thornode supports Bitcoin and Ethereum transactions, it will have to run nodes for both networks. Thornodes have access to vaults on the chains they can interact with and can sign transactions of these vaults via TSS majority. A node will observe chain A for locking of funds and will release funds on chain B as the lockup is completed. The diagram below shows a highly simplified version of how tokens are exchanged.
Since Thorchain is not just a bridge but also an exchange it works with liquidity pools. Liquidity providers can deposit funds per chain to ensure swapping of tokens and earn yield. To initiate a swap from ETH to BTC a wallet per chain needs to be connected, once funds are sent, Thornodes observe processing of the transaction into the vault. Once completed the outbound transaction for BTC is signed and the user receives BTC for his ETH.
Bridging via Thorchain is dependent on validators of a different chain and the approach of TSS very similar to a multisig smart contract, controlling the funds.
It is worth bringing all these differences in between chain options into one view:
There are as many bridges as there are chains and I am certainly missing a bunch here. As the ecosystem is evolving, moving tokens between chains will be much easier and this in turn will allow more chains to exist. If tokens can be transferred over and there is some benefit for the Dapp to use a particular chain, then there is nothing holding back an open ecosystem. This could one day move chains into the background. Users of an app don’t care whether it is running on Ethereum, Solana or Terra, as long as the user can borrow money at a good rate.
Raoul Pal recently joined the Bankless Podcast and I recommend listening to the episode. He described a future where you can send tokens to a wallet without bothering what chain the other person’s wallet is on. The underlying technology — the bridges — will take care of this aspect. You can receive a call from someone without knowing what network provider he is with and what cell phone tower you are connected to. Crypto still has a lot to improve on and bridges play a big role here.