The Stakenet Layer 2 Wallet

Stakenet Team
Apr 17 · 4 min read

As development of the Stakenet Web Dex is making progress, we wanted to give you an update on the user experience you can expect when interacting with the dex. In order to interact with the Stakenet Web DEX architecture, you will need to have a Layer 2 wallet connected to the hubs. A Layer 2 Wallet has a few key differences from a Layer 1 Wallet, so make sure to read the following explanations:

A Layer 2 wallet exists as a combination of a multisig smart contract deployed to an EVM chain, and a set of state channel connections to the Stakenet Hubs. One component of the wallet (that being the smart contract) is responsible for moving funds on- and off-chain, whereas the corresponding state channel which is the other component, is responsible for tracking the state of the off-chain network.

The wallet itself is provided by Connext, a Layer 2 state channel protocol built atop EVM blockchains. As a user, you will never have to deal with these two halves directly, but rather the abstraction of the wallet as a whole.

Welcome to your Layer 2 Wallet

Each user will go through a quick setup procedure to create their wallet. The one time Layer 2 wallet creation will incur a small gas fee. This one time transaction fee is required because the smart contract half of the wallet will need to be deployed to your mainnet of choice (e.g. Ethereum or Binance smart chain).

Creating a wallet will result in a unique seed phrase, similar to the current Layer 1 wallet creation. After the initial setup you will be able to encrypt the seed phrase with a password, which will be required upon each visit to the dex.

Unlike a standard Layer 1 wallet (MyEtherWallet, MetaMask etc.), which you are most likely to be familiar with, a Layer 2 wallet can only exist in one place at a time. The state channel half of the Layer 2 wallet is held in local storage on your device, and therefore can only exist on one device at a time.

Your seed phrase will be used to to transfer your wallet between devices or browsers, as well as recover your wallet if your browser loses its cache. (More information on transferring your state channels can be found below).

Though the wallet will feel similar to those on centralized exchanges, it will exist entirely within your browser, and you will be in control of the seed phrase and private keys at all times. Get a glimpse of our current work here:

Depositing & Withdrawing funds from Layer 2 Wallet

The Layer 2 wallet acts as an address to hold your funds securely and trustlessly while you make trades in the Layer 2 state channels. To ‘on-ramp’ (deposit) funds, simply send them to your Layer 2 wallet address, either from your own private wallet, or from a centralized exchange.

‘Off-ramping’ (withdrawing) is done through interaction with the wallet smart contract, and these interactions can be done through the Stakenet Web Dex. Off-ramped funds can be sent to either your private wallet or a centralized exchange.

Both on- and off-ramping incur a gas fee, though in testing this gas fee is about 1/10th the price of a standard uniswap transaction, and only has to be paid once. Your funds can exist in a Layer 2 state indefinitely so the on- and off-ramp events can be executed rarely.

Connext state channels

State channels exist as direct connections from your local Layer 2 wallet to the Stakenet Hub, and thus conducting a transaction simply updates the state of both your own wallet, and the Stakenet Hub itself. These transactions are trustlessly signed at both ends of the channel, and do not incur a gas fee, as they do not ever touch the underlying blockchain.

During an off-ramp event the states of these channels allows the underlying blockchain to execute all the necessary trades concurrently in a single transaction.

Theoretically, an infinite amount of transactions could occur in Layer 2 state channels, all of which compress into one single transaction during off-ramping.

Why can’t I just use Metamask?

Metamask is a Layer 1 wallet, and does not support the infrastructure to connect with the Stakenet Hub Architecture. Instead, Metamask will be used to facilitate the on-ramp and off-ramp flow, without manually copying and pasting addresses. Funds can be directly loaded and withdrawn through the Web3 API.

Transferring state channel information

Because state channel information is held locally on your device, it takes special care to ensure its integrity. The Stakenet Architecture guards this integrity in two ways, with backups of the Hubs state channels (the other half of your channels), and with watchtowers, which periodically back up the states of all users in the network. We have already included a first version of off-chain watchtowers in our Stakenet DEX (open beta) in summer 2020.

When switching devices or browsers, you will have to enter your seed phrase to reconnect to your wallet, and the most recent state of your Layer 2 channels will be delivered to you automatically by the Stakenet Hub. For extra security in the future, we will also be implementing a way to back up your states locally, which will be executed after each and every transaction. This allows you to ensure your own data integrity against attacks of any kind.

Check the progress of the Stakenet Web DEX on our public github here: https://github.com/X9Developers/stakenet-web-ui

Join us on Discord and follow us on Twitter to stay up-to-date with our latest news and developments.

Stakenet (XSN)

Stakenet (XSN) revolutionizes the way cryptocurrencies are…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store