Building a UI for Moving Tokens In and Out of Layer 2

Bryan P
3 min readFeb 11, 2020

The promise of layer 2 — The elimination of gas fees and network congestion. — Is real.

Mass adoption narratives require that users never worry about the tech and cost limitations inherent to Mainnet. They need to have zero barriers. Cryptoraves is one such vision that is not viable given such barriers, so that’s why I chose to build it using a layer 2 solution via @loomnetwork’s public Basechain. End user transaction fees on our platform are thus eliminated. Achievement achieved.

Best viewed while listening to some Floyd

The launch of a platform that could take specifically formatted Tweets and translate them into blockchain transactions was essential for this to come to fruition. That was relatively simple, but has since evolved drastically. We currently offer 4 kinds of transactions: Launch a token. Transfer token(s). Deposit from Mainnet. And Withdraw to Mainnet. The latter two are the most recent additions and allows for any Mainnet token to be ported into the Cryptoraves ecosystem. And our first partnership is in fact due to this development.

So this key component of the vision, to allow for the free flow of tokens to and from Layer 1 and Layer 2 required a web3 capable user interface . Done and done — Here’s the open source Github repo. The core functions interact with what @loomnetwork calls the Gateway between L1 and L2. The code involving the Gateway makes up the bulk of the complexity of the system.

Scaled down image of the actual Gateway as it appears on the blockchain.

How’s it work? As a prerequisite, a smart contract must be launched onto each layer (if not already). Then a command is sent to each Gateway contract on the respective layers from the contract owner accounts to map these contracts together forever. The gateway links these two contracts and thus allows the passing of tokens through. Token passage is done via a process of a.) locking the tokens on the deposit side and b.) minting tokens on the withdraw side. And this can go either way! Considering we’ve launched over 1000 Layer 2 native tokens, we’ve certainly considered the need that many of them want to take flight to L1 Mainnet. And that is coming very soon.

The Cryptoraves Web3 Portal allows users to map their account addresses through the gateway in a similar fashion. The steps are as follows:

  1. ) For security our user must tweet their address:

2.) After that she goes to the Cryptoraves web3 portal and with 1 click, performs this mapping operation. This is a seamless act as Loom provides Universal Transaction Signing. Means as long as you have your L1 keys, you never have to worry about your L2 keys. Crucial streamlining feature!

3.) Profit. You can now carry out the deposit / withdraw features as many times as you like and without any non-gas-related fees!

The dev journey was arduous, frustrating, and rewarding. And as of the time of this writing I’m heading to Eth Denver for the renown hackathon there (HMU! HMU!) and even though I’ve just done my own 2-month long hackathon for the above project, I’m still very excited to see what happens. Then perhaps a vacation?

--

--

Bryan P

Integralist. Founder @Cryptoraves . Fosterer of other flighty ideas.