Interchain Transaction Bridge - The Missing Key to Creating Seamless UX in a Multi-chain Universe

Written by weitingchentw | Published 2021/04/10
Tech Story Tags: bitcoin | derivatives | ethereum | web3 | cryptocurrency | dex | decentralized-exchange | hackernoon-top-story

TLDR Interchain Transaction Bridge - The Missing Key to Creating Seamless UX in a Multi-chain Universe. Despite it being easy to port an existing. dapp to an EVM-compatible chain like xDai Chain or Binance Smart Chain, the UX remains tricky. In this piece, we’ll dive into the problems that users face when using a dapp on another chain, how Interchain. It’s not surprising that most users will bail out part way through the process.via the TL;DR App

In light of increasingly high gas fees on Ethereum, various DeFi protocols have migrated their services to L2 solutions or launched directly on Ethereum-compatible chains instead of Ethereum itself. Due to the nascency of L2 solutions, many DeFi protocols are adopting the latter approach. 
However, despite it being easy to port an existing Ethereum dapp to an EVM-compatible chain like xDai Chain or Binance Smart Chain (BSC), the UX remains tricky.
In this piece, we’ll dive into the problems that users face when using a dapp on another chain, how Interchain Transaction Bridge (“ITB” for short) solves the problem, followed by a case study.

Problems from a user’s POV

If you mainly use Ethereum dapps on your desktop, chances are you have Metamask installed. And to interact with dapps on a non-Ethereum chain for the first time, you need to change a bunch of settings in Metamask. Here is what the process looks like:
Yikes! It’s not surprising that most users will bail out part way through the process. 
At the other end of the spectrum, we have mobile-only users. For this kind of user, if the mobile wallet they use does not support the chain that a dapp resides on, they cannot use it at all. For instance, if you’re using Argent, you cannot use Pancakeswap (Uniswap equivalent on BSC) or Venus (Compound equivalent on BSC)—simply because the wallet doesn’t support BSC.
Furthermore, sometimes a protocol has different settings on another chain. For instance, Cream Finance, a money market on Ethereum, Fantom and BSC chains, has a separate asset list for each chain for users to borrow and lend (19 assets on Fantom, 33 assets on BSC and more than 50 assets on Ethereum). As a result, users need to switch their network settings to see each chain’s supported assets, creating a UX nightmare.
Most troubling for new users, a given token will likely have different variants on different chains. For example, USDC on xDai and USDC on BSC are entirely different, incompatible tokens.
The last problem is that you need to hold different gas tokens for each chain - BNB for the BSC chain, xDAI for the xDai chain, FTM for Fantom, etc. Gas fees for each chain also vary wildly: 1 Gwei is normally fine on xDai, whereas BSC enforces a 10 Gwei minimum. Nativating gas fees is already difficult for many users, and adding base multiple tokens to the mix only makes things worse. 
(Update on 2021/3/5)
While this article was under review, Metamask implemented EIP-3085 to allow dapp developers to add a button on their site. Users can click the button to add a new chain setting on their Metamask and subsequently switch to that chain - a significant improvement indeed.

How Interchain Transaction Bridge solves these problems

The goal of ITB is to let you go to a non-Ethereum dapp website, connect your wallet (Metamask and mobile wallets alike), and start using the dapp as if the application was on Ethereum. That’s it. You don’t need to know which chain the dapp is on. You just go to the site and start using it like any modern web application. 
And this functionality is available and working today.
Under the hood, when you send out a transaction, it is passed automatically to the chain where the smart contracts reside. That’s the reason why this technique is named “Interchain Transaction Bridge.” What’s more, using this technique, any gas fees on the non-Ethereum chain are covered by the dapp developer, and transactions typically confirm in seconds.
Sounds too good to be true, you might wonder. 
In the next section, we’ll look at an example of this in a live environment. To our knowledge, our use of this technique at Perpetual Protocol is the first of its kind. 
If you can’t wait to try it yourself, please go to https://perp.exchange.

How Interchain Transaction Bridge works

To begin with, it will help to understand what Perpetual Protocol is before explaining how ITB works.
Perpetual Protocol is a decentralized exchange where you can connect your wallet and directly speculate on an asset’s price movement, with leverage if desired. To open a leveraged position, users need to deposit USDC and use that as collateral for the position. If you open a long position and the underlying asset’s price increases, it’s a profitable trade for you (or a loss, in the opposite case).
Because everything happens on-chain on Perpetual Protocol, trade consumes lots of gas (i.e., computing power) on the blockchain. To give you some context, each trade would cost around 100 USD worth of gas if the transaction were on Ethereum. As such, we migrated the smart contracts to the xDai Chain, an Ethereum-compatible chain where each trade costs 0.005 USD on average.
Unfortunately, not that many people knew about xDai Chain when the protocol launched in December 2020. And the previously mentioned problems (setting up Metamask; users needing native tokens to pay for gas on another chain) promised to make adoption very challenging. 
To overcome this, Perpetual Protocol’s developers came up with the idea of ITB, allowing users to trade on another chain without even realizing it.
There are two components to make ITB possible - meta transactions and an on-ramp/off-ramp process.
Meta Transactions 
Normally, when we send transactions, the wallet will submit signed transactions to a blockchain, as the diagram below shows.
However, for meta transactions, the wallet will pass the signed message and other parameters to an automated relayer. The relayer then submits the transaction to a different blockchain. The user benefits from the cheaper, faster chain without having to do anything.
On-ramp/Off-ramp process
The next step is the on-ramp/off-ramp process, which users rely on to deposit and withdraw their funds to and from the xDai Chain. 
There are three steps involved in the single trip:
1. Grant permission to move USDC on Ethereum
The on-ramp process’s end goal is to migrate users’ USDC to the xDai Chain, so the first step is to ask users to permit our smart contract to move the USDC on behalf of them. 
2. Transfer Tokens to the xDai Bridge
Followingly, users need to transfer the amount of USDC they want to deposit to the Ethereum side of the xDai Bridge. The Bridge will safeguard the deposited USDC until users request to withdraw their funds from the xDai Chain.
Users don’t need to pay gas fees after this step.
3. Grant permission to move USDC on xDai Chain
Once the amount of USDC deposited is credited to users’ addresses on the xDai Chain, users need to grant our smart contracts on the xDai Chain permission to use their USDC on the xDai Chain. From this point on we use meta transactions to execute users’ trades to the xDai Chain.
Now, users can start trading on Perpetual Protocol without paying gas fees (they just need to sign a message on their wallets, like the one below)!
The off-ramp process is much the same, only in reverse. Users approve USDC to be moved to the xDai side of the xDai Bridge. In turn, the Ethereum side of the xDai bridge releases USDC on Ethereum back to users’ wallets.

Cons of the Interchain Transaction Bridge

Each design comes with trade-offs, and the ITB is no exception.
There are two shortcomings of the ITB:
1) Limited Hardware Wallet Support
Due to technical limitations, Trezor users can’t use the ITB, and Ledger functionality is very limited. Neither of these popular hardware wallets will work with the ITB when connected to Metamask. But the developers can use the aforementioned new Metamask feature (EIP-3085) to switch network settings so that hardware wallet users can use the dapp once they’ve sent their funds to the secondary chain (still no gas fees thanks to meta transactions).
2) Limited Applicability 
Only certain types of dapps can adopt the ITB, such as synthetic assets trading, derivative trading, or margin trading. For other services like spot trading, users expect to receive the exchanged assets on the same chain once a transaction concludes so the ITB won’t work unless all assets swapped are already on the secondary chain.

Closing Out

We believe that the ITB is the missing key to creating a seamless UX in this multi-chain Universe. It enables users to interact with a dapp as if the dapp resided on Ethereum. Additionally, by combining with the latest feature from Metamask, this technique can cover almost every type of wallet.
There’s no better way to learn than by doing! Give https://perp.exchange a try and experience it first-hand. 



Written by weitingchentw | Building new bricks for Ethereum money lego.
Published by HackerNoon on 2021/04/10