/light-client

The Raiden Light Client

Primary LanguageTypeScriptMIT LicenseMIT



Raiden Light Client SDK and dApp

JavaScript SDK and dApp to carry out fast, cheap, scalable off-chain token transfers with other Raiden Clients.

Getting StartedContact

Try Out the Raiden Demo dApp

CircleCI Badge Codecov Badge code style: prettier Gitter Raiden Badge

The Raiden Light Client SDK is a Raiden Network compatible client written in JavaScript/Typescript, capable of running in modern web3-enabled browsers, wallets and Node.js environments.

The Raiden dApp is a reference implementation of the Raiden Light Client SDK, which can be used with web3 wallets like Metamask (Desktop) or imToken (mobile).

INFO: The Light Client SDK and dApp are work in progress and can only be used on the Ethereum Testnets.

Table of Contents

About The Project

The Raiden Network is an off-chain scaling solution, enabling near-instant, low-fee and scalable payments. It’s complementary to the Ethereum blockchain and works with any ERC20 compatible token.

The Raiden client code is available here and has been released for mainnet with a limited alpha release of the Raiden Network in December 2018.

The goal of the Raiden Light Client SDK is to provide an easy-to-use framework, which can be integrated by any JavaScript developer. The SDK will simplify the process of embedding and using the Raiden Network for token transfers in decentralized applications

With the SDK we want to make your life as a dApp dev easier:

  • You should be able to interact with the Raiden Network easily with your dApp.
  • We want to help you to enable your users to make token transfers using their consumer wallets like imToken or Metamask.
  • It should be possible to send tokens using low end devices, which would not be capable of running a full Raiden node.

Architecture

Raiden Light Client SDK

This is a standalone Typescript library which contains all the low level machinery to interact with the Ethereum blockchain and the Raiden Network.

Its target audience is blockchain and dApp developers looking into interacting with and performing transfers through the Raiden Network from their apps. Targeting browsers and Node.js as initial platforms allows it to reach the majority of current and in-development dApps, as well as to work as a common language reference implementation for ports and re-implementations in other future languages and environments.

Look at the Raiden Light Client SDK folder of this repository for more information. Also, a technical deep dive into the SDK architecture, technologies, tips and details on the design goals and decisions can be found in the project's Wiki page. Reading it is highly recommended to anyone wishing to better understand how the Raiden Light Client works under the hood or to contribute to it, though not required to use this library as a dApp developer.

Architecture diagram

            +-------------------+
            |                   |
            |   Raiden dApp     |
            |                   |
            |  vue/vuex/vuetify |
            |                   |
            +---------+---------+
            |                   |
            |    Raiden SDK     |
            |                   |
            +----+----+----+----+
            |         |         |      +------------+
         +--+  redux  +  epics  +------+ Matrix.org |
         |  |         |         |      +-----+------+
         |  +---------+-----+---+            |
         |                  |          +-----+------+
+--------+-------+   +------+------+   |   Raiden   |
|  localStorage  |   |  ethers.js  |   |   Network  |
+----------------+   +------+------+   +------------+
                            |
                     +------+------+
                     |  ethereum   |
                     +-------------+

Getting Started

Learn about Raiden

If you didn't use Raiden before, you can

Try Out the Raiden Demo dApp

The Raiden dApp is the demo and first dApp user of the SDK. It's a single page application (SPA) built on top of Vue.js, vuex and vuetify as UI framework which uses Material Design as the design guideline.

These step-by-step instructions will guide you through the process for trying out the Raiden demo dApp. The dApp is hosted at https://lightclient.raiden.network/ and we will be using the Goerli testnet and MetaMask wallet in this example.

Prerequisites

  1. You need to have MetaMask installed for your browser. If you don't have MetaMask, visit their website to download and install it.
  2. It is NOT recommended to use the dApp on mobile (but it works).

Steps to Make Your First Transfer

1. Acquire ETH

  1. Go to the Goerli faucet at htts://faucet.goerli.mudit.blog or https://goerli-faucet.slock.it/
  2. Follow the instructions on how to acquire Goerli ETH on respective website

2. Navigate to the Raiden Hub

  1. Visit the Raiden Hub Page at https://hub.raiden.network/
  2. Click Open Channel with Hub to get forwarded to https://lightclient.raiden.network/

3. Connect to the Raiden dApp

  1. Click Connect to connect the dApp to your MetaMask

4. Select a Hub and Open a Channel

  1. Click the mint button next to your token balance, to mint some TTT tokens.
  2. Click Select Hub
  3. Enter the amount of TTT Tokens you want to deposit when opening a channel with the hub
  4. Sign the deposit with your MetaMask.
  5. Click Open Channel.
  6. Sign "Open Channel", "Approve" and "Set Total Deposit" with your MetaMask when prompted

5. Make a transfer

  1. Enter the address of the node receiving your transfer (eg. hub.raiden.network)
  2. Enter the amount you want to transfer
  3. Click Transfer

Backup the State to Keep Your Tokens

Store a backup of your state to avoid loosing tokens in case you:

  • Delete your local browser storage
  • Change your computer
  • Change your browser

If you want to continue using the dApp with a specific account when switching browser or changing computer you need to make sure that the dApp is connecting with the most recent state.

This is important because your state contains all the off-chain information which is needed to make transactions in the Raiden Network. Your state is stored in the browser across sessions and therefore it needs to be downloaded and uploaded whenever you switch browser or change computer.

You can download and upload your state via the General Menu. Note that if you loose or delete your state you will also loose your tokens.

Structure of the state file:

{
  "address": "0x2a23F385d32dcce35824D4498Bb10f9B6575B2de",
  "version": 2,
  "chainId": 5,
  "registry": "0x9b0c8C8C75904CEf5B7a8dbF59c3459Ea85c6526",
  "blockNumber": 2561973,
  "config": {},
  "channels": {},
  "tokens": {
    "0xE2b702eD684bEb02850ac604278f078A4ce8b6E6": "0x2001E8851d33CA476e209e37ED8db1BB9E72334F"
  },
  "transport": {},
  "sent": {},
  "received": {},
  "path": { "iou": {} },
  "pendingTxs": []
}

Run Repository Code

Prerequisites

To run the code in this repository, you must have Node.js 10+ on your computer and a web3-enabled browser (e.g. Firefox with Metamask extension), as well as some ETH on the account.

SDK Documentation

Go to the SDK Documentation for more information on how to install and use the SDK.

dApp Installation

git clone --recurse-submodules https://github.com/raiden-network/light-client.git
cd light-client/raiden-dapp

Build the Raiden SDK

First you need to build the sdk. For this you have to go to the raiden directory and run the following commands.

cd ../raiden-ts
npm install
npm run build

Install the dApp Dependencies

Then you need to install the wallet app dependencies.

cd ../raiden-dapp
npm install --save raiden-ts

This will also create a symbolic link in raiden-dapp/node_modules/raiden-ts to raiden-ts.

Running the dApp locally

To start the development server you have to run the following command.

npm run serve

After the development server starts you have to navigate to http://localhost:8080, in order to use the Raiden dApp. It requires either MetaMask to be installed on your browser or some other web3 provider (e.g. Wallet apps with dApp support).

Roadmap and Timeline

We are working in 2 weekly iterations. Priorities are managed within the Product Backlog.

With the first testnet release we have reached milestone 0, where the SDK and dApp are able to send transfers, but will not be able to receive transfers.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

Also have a look at the Raiden Light Client Development Guide for more info.

License

Distributed under the MIT License.

Contact

Dev Chat: Gitter

Twitter: @raiden_network

Website: Raiden Network

Mail: contact@raiden.network

Project Link: https://github.com/raiden-network/light-client