Bridging assets between Near and Ethereum with the Rainbow bridge
On day 3 of my writing challenge, I’m writing about the Rainbow Bridge. Other people do Squats or Pushups for a challenge; I train my writing muscles. ✍️
As the name suggests, Rainbow is a bridge. So let’s start with why we need bridges in the first place and what they do.
Bridges in General
At the moment, there are a variety of blockchain ecosystems out there people can use. Let’s say you buy one Bitcoin. Then you realize that there isn’t much DeFi happening on Bitcoin. Instead of directly selling it, you might notice opportunities in Ethereum. If you are a Hodler by conviction and want to earn some yield, you can try and get your Bitcoin into the Ethereum ecosystem. The way to do it are bridges.
A bridge connects different blockchain ecosystems and facilitates token movements between them. Generally, we can differentiate between centralized bridges and those that are trustless. Centralized bridges work similarly to a centralized exchange in that they will take your assets into custody and then issue the asset on the other chain for you. An example for Bitcoin would be wrapped Bitcoin. It’s a service offered by a group of blockchain companies that still requires users to trust the intermediary.
Trustless bridges, however, are entirely governed through code and sometimes maintained by DAOs that incentivize their members to facilitate bridging.
The Rainbow Bridge
The Rainbow Bridge is a bridge connecting the Ethereum and the Near ecosystem. It was launched in April 2021 and has since facilitated transfers in and out of Ethereum to Near. The bridge enables a seamless integration of assets and contracts between Ethereum and NEAR.
The Rainbow bridge is trustless. As the team explains, “You only need to trust what it connects, the NEAR and Ethereum blockchains, and you don’t need to trust the bridge itself. There is no authority outside Ethereum miners and NEAR validators.” There is no single actor who could halt the chain, or remove assets flowing between the ecosystem. Users retain full custody of their holdings during the bridging process.
How it works
To enable the bridging, the system relies on two light clients
- Ethereum light client in Rust set up as a NEAR contract
- NEAR light client implemented in Solidity as an Ethereum smart contract
Light clients are software that can verify transactions and the state of a blockchain without having to do any heavy computations. Most of the wallets you use to interact with Web3 are light clients. These light clients are made more useful through the addition of a prover. This prover can prove that something happened on a blockchain, which is handy when you need to know that assets have been moved.
In addition to that, three further services, two relayers, and so-called watchdogs facilitate token transfers.
For a user, all they see is the web interface, where they add funds, specify a recipient address, and then wait for it to complete. In the backend, the tokens from chain A (Ethereum) are locked in favor of the recipient, and only once the proof of that locking is submitted on the other chain (NEAR) and verified using the prover tokens are minted on NEAR to represent the tokens bridged from Ethereum.
As you can see, unlike crossing a real bridge, the tokens don’t come out of the other ecosystem as they enter the bridge. In fact, they are locked on one and minted newly on the other. That is why I personally find the term bridge a bit confusing.
That aside, the Rainbow Bridge is a very easy-to-use application where you can use your MetaMask to move assets across Aurora, Ethereum, and NEAR.
But wait a minute. Aren’t bridges the thing getting hacked all the time?
True that. It seems that bridges in DeFi get hacked every other day, Nomad being the most recent victim. What’s interesting, though, with Rainbow is that the one time an attacker tried, they famously failed and lost 2.5 ETH in the process.
In May 2022, a hacker tried to exploit the bridge using funds from Tornado Cash. Essentially, they’d try to establish themselves as a relayer and submit fabricated blocks — showing that they’d be receiving funds when there had never been any actual funds entering.
On the first attempt, they failed; their second succeeded and resulted in a successful transaction. However, one of the watchdog bots created a challenge transaction because they realized that the block wasn’t in the NEAR blockchain. Long story short, an MEV bot front ran the challenge transaction resulting in a 2,5 ETH loss for the hacker.
So for those looking to escape the high gas fees on Ethereum and wanting to explore the NEAR ecosystem, the rainbow bridge is a great entry point. Nevertheless, as always, when money is at risk, just bridge what you can afford to lose.
Happy Bridging!