Skip to content

raiden-network/light-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Raiden Logo
Raiden Light Client SDK, CLI and dApp

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

Getting StartedContact

Try Out the Raiden dApp

CircleCI Badge Codecov Badge Code Climate Badge Code Style: prettier Badge 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 CLI is a reference implementation that provides a HTTP REST server which is fully compatible with the Raiden API specification.

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, CLI and dApp are all work in progress projects. All three projects have been released for mainnet and all code is available in the Light Client repository. As this release still has its limitations and is a beta release, it is crucial to read this readme including the security notes carefully before using the software.

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.

Raiden Diagram

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 simplifies the process for developers to embed and use the Raiden Network for token transfers in decentralized applications

The SDK aims to make the life of dApp developer easier by:

  • Enabling dApps to easier interact with the Raiden Network.
  • Helping users to make token transfers using consumer wallets like MetaMask and imToken.
  • Enabling transferring and receiving tokens using low-end devices.

Architecture

The Raiden Light Client SDK 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 to perform transfers in the Raiden Network from their dApps.

By targeting browsers and Node.js as initial platforms, the SDK can reach a majority of the current and in-development dApps, as well as providing a common language reference implementation for re-implementations in other languages and environments.

Look at the Raiden Light Client SDK folder of this repository for more information and a technical deep dive into the SDK architecture, technologies and details on the design goals and decisions.

Reading the documentation is highly recommended for anyone who wishes to better understand how the Raiden Light Client works under the hood or wants to contribute to its development.

Architecture diagram

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

Learn about Raiden

If you are new to Raiden, we recommend:

Try Out the Raiden dApp

Before trying out the dApp, make sure that you've read and understood the requirements for safe usage

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

These step-by-step instructions will guide you through the process for trying out the Raiden demo dApp.

The dApp is hosted on https://lightclient.raiden.network and in this quick start guide we will be making a transfer using the Light Client on both mainnet and the Goerli testnet with the MetaMask wallet.

For a more in depth user guide, see the Light Client documentation.

Prerequisites

For these step-by-step instructions the MetaMask browser extension will be used. Make sure MetaMask is installed on your browser. the plugin can be downloaded from their website. Alternatively WalletConnect can be used for connecting with supported wallets, note that this is an experimental feature limited to how well any of the external wallets integrate with WalletConnect.

An ETH balance is also needed. For mainnet you'll have to purchase ETH, for the Goerli testnet you can acquire some test ETH by:

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

Making a First Transfer on Mainnet

  1. Connect to the dApp

    • Connect using the Browser Extension

      1. Visit the Light Client.
      2. Make sure Ethereum Mainnet is selected in MetaMask.
      3. Click on Browser Extension.
      4. Click on Connect and sign the messages on MetaMask to establish a connection.
    • Connect using WalletConnect

      1. Visit the Light Client.
      2. Click on WalletConnect.
      3. By default a bridge server provided by WalletConnect is used. It is however possible to use an alternative bridge server.
      4. Choose to provide either an Infura ID or a RPC endpoint.
      5. Click on Connect.
      6. Scan the QR code using a wallet of your choice. Make sure mainnet is used and sign all necessary signatures.
  2. Select a Hub and Open a Channel

    1. Click the + icon and select a mainnet token to use. You need to have a balance of the token.
    2. If you don't have any RDN (utility tokens), you can click the icon to open a dialog with a link for exchanging RDN and a button for depositing.
    3. Enter an address of your choice to connect to or select a suggested hub if any are available.
    4. Click the Select Hub button
    5. Enter the amount of tokens you want to deposit when opening the channel.
    6. Click the Open Channel button and sign with MetaMask.
  3. Make a Transfer

    1. Enter the address of the node receiving your transfer.
    2. Enter the amount you want to transfer.
    3. Click the Transfer button.

Making a First Transfer on Testnet

  1. Connect to the dApp

    1. Visit the Raiden Hub page.
    2. Click on the Open Channel with Hub button.

    When redirected to the Light Client choose to connect by using either:

    • Browser Extension

      1. Make sure Goerli Test Network is selected in MetaMask.
      2. Click on Browser Extension.
      3. Click on Connect and sign the messages on MetaMask to establish a connection.
    • WalletConnect

      1. Click on WalletConnect.
      2. By default the bridge server provided by WalletConnect is used. It is however possible to use an alternative bridge server.
      3. Choose to provide either an Infura ID or a RPC endpoint.
      4. Click on Connect.
      5. Scan the QR code using a wallet of your choice. Make sure Goerli Test Network is used and sign all necessary signatures.
  2. Select a Hub and Open a Channel

    1. If you don't have any SVT (utility tokens), you can click the icon to mint and deposit SVT.
    2. Click on the icon at the very bottom to the right of the TTT symbol to mint TTT tokens.
    3. Click the Select Hub button.
    4. Enter the amount of tokens you want to deposit when opening the channel.
    5. Click Open Channel and sign with MetaMask.
  3. Make a Transfer

    1. Enter the address of the node receiving your transfer.
    2. Enter the amount you want to transfer.
    3. Click the Transfer button.

Receiving Transfers

Receiving of transfers will be disabled if the utility token (RND on mainnet and SVT on testnet) balance is too low.

To enable receiving again, make sure to add a utility token balance by either making an exchange and deposit if using the Light Client on mainnet or by minting and depositing if using the Light Client on testnet.

Backup the State to Keep Your Tokens

You should store a backup of your state to avoid losing tokens in case:

  • You delete your local browser storage.
  • You change computer.
  • You use another browser.

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

This is important because the state contains all off-chain information needed for making transactions in the Raiden Network.

The state is stored in the browser across sessions and therefore needs to be downloaded and uploaded whenever you switch browser or computer.

You can download and upload the state from the General Menu.

If you lose or delete your state you will also lose your token.

Example of a part of the JSON state file:

[
  {
    "_id": "_meta",
    "version": 2,
    "network": 5,
    "registry": "0x9b0c8C8C75904CEf5B7a8dbF59c3459Ea85c6526",
    "address": "0x2a23F385d32dcce35824D4498Bb10f9B6575B2de",
    "blockNumber": 2561973
  }
]

Run the Repository Code

Prerequisites

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

SDK Documentation

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

CLI Documentation

Go to the CLI README for installation instructions and the current status of the API.

Install and Run the dApp

  1. Clone repository

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

    yarn install
  3. Update the sdk submodules

    yarn workspace raiden-ts update-submodules
  4. Build the Raiden SDK

    yarn workspace raiden-ts build
  5. Run the dApp locally

    yarn workspace raiden-dapp serve
    

    After the development server starts, navigate to http://localhost:8080 to use the Raiden dApp.

Requirements for Safe Usage

In order to use Raiden correctly and safely there are some things that need to be taken care of by the user:

  • Layer 1 works reliably: That means that you have got a web3 provider (eg. MetaMask) that is always synced and working reliably. If there are any problems or bugs on the client then Raiden can not work reliably.

  • Persistency of local DB: Your local state database is stored in your browser storage (IndexedDB). This data should not be deleted by the user or tampered with in any way. Frequent backups are also recommended. Deleting this storage could mean losing funds.

Roadmap and Timeline

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

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.

Bug Bounty

The Raiden team has undertaken several risk mitigation measures to limit any potential damage caused by bugs or misuse of the software. In addition, a bug bounty is run in order to make sure the software lives up to the highest standards possible. For more information and to participate visit the Raiden Bug Bounty website.

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