raiden-ts
Version:
Raiden Light Client Typescript/Javascript SDK
295 lines • 17.3 kB
HTML
<html class="default no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Overview | raiden-ts - v3.1.1</title>
<meta name="description" content="Documentation for raiden-ts - v3.1.1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../assets/css/main.css">
<link rel="stylesheet" href="../../assets/css/pages.css">
<script async src="../../assets/js/search.js" id="search-script"></script>
</head>
<body>
<header>
<div class="tsd-page-toolbar">
<div class="container">
<div class="table-wrap">
<div class="table-cell" id="tsd-search" data-index="../../assets/js/search.json" data-base="../..">
<div class="field">
<label for="tsd-search-field" class="tsd-widget search no-caption">Search</label>
<input id="tsd-search-field" type="text" />
</div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li>
</ul>
<a href="../../index.html" class="title">raiden-ts - v3.1.1</a>
</div>
<div class="table-cell" id="tsd-widgets">
<div id="tsd-filter">
<a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a>
<div class="tsd-filter-group">
<div class="tsd-select" id="tsd-filter-visibility">
<span class="tsd-select-label">All</span>
<ul class="tsd-select-list">
<li data-value="public">Public</li>
<li data-value="protected">Public/Protected</li>
<li data-value="private" class="selected">All</li>
</ul>
</div>
<input type="checkbox" id="tsd-filter-inherited" checked />
<label class="tsd-widget" for="tsd-filter-inherited">Inherited</label>
</div>
</div>
<a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a>
</div>
</div>
</div>
</div>
<div class="tsd-page-title">
<div class="container">
<ul class="tsd-breadcrumb">
<li>
<a href="../../modules.html">raiden-ts - v3.1.1</a>
</li>
<li>
<a href="README.html">Using the Raiden CLI</a>
</li>
<li>
<a href="README.html">Overview</a>
</li>
</ul>
<h1>Overview</h1>
</div>
</div>
</header>
<div class="container container-main">
<div class="row">
<div class="col-8 col-content">
<div class="tsd-panel tsd-typography">
<!-- PROJECT SHIELDS -->
<h2 align="center">
<br/>
<a href='https://raiden.network/'><img
width='400px'
alt=''
src="https://user-images.githubusercontent.com/35398162/54018436-ee3f6300-4188-11e9-9b4e-0666c44cda53.png" /></a>
<br/>
Raiden Light Client CLI
<br/>
</h2>
<h4 align="center">
Node.js command line application using the <a href="https://github.com/raiden-network/light-client/tree/master/raiden-ts">Raiden Light-Client SDK</a>
</h4>
<p>The goal of the CLI is to provide a HTTP REST server that is fully compatible with the <a href="https://raiden-network.readthedocs.io/en/latest/rest_api.html">Raiden API specification</a>. It uses the Raiden Light Client SDK internally.</p>
<p>The CLI is considered experimental and mostly used for testing internally, not yet stable enough for production usage. Be aware that not all endpoints the specification defines are implemented yet.</p>
<p>It requires the latest <a href="https://github.com/nodejs/Release">Node.js LTS (14.x - Fermium)</a></p>
<blockquote>
<p><strong>INFO:</strong> The Light Client SDK, dApp and CLI are <strong>work in progress</strong> and can only be used on the Ethereum <strong>Testnets</strong>.</p>
</blockquote>
<a href="#requirements-for-safe-usage" id="requirements-for-safe-usage" style="color: inherit; text-decoration: none;">
<h2>Requirements for Safe Usage</h2>
</a>
<ul>
<li><p><strong>Layer 1 works reliably:</strong> 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.</p>
</li>
<li><p><strong>Persistency of local DB:</strong> Your local state database is stored in a Leveldown database at <code>--datadir</code> path (default <code>./storage</code>). 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.</p>
</li>
<li><p><strong>Raiden account has sufficient ETH:</strong> Raiden will try to warn you if there is not enough ETH in your Raiden account in order to maintain your current open channels and go through their entire cycle. But it is your job as the user to refill your account with ETH and always have it filled.</p>
</li>
<li><p><strong>Raiden always online:</strong> Make sure that your node is always working, your network connection is stable and that the Raiden node is always online. If it crashes for whatever reason you are responsible to restart it and keep it always online. We recommend running it inside some form of monitor that will restart if for some reason the Raiden node crashes.</p>
</li>
<li><p><strong>Ethereum client always online:</strong> Make sure that your Ethereum client is always running and is synced. We recommend running it inside some form of monitor that will restart if for some reason it crashes.</p>
</li>
<li><p><strong>Ethereum client is not changed:</strong> Swapping the Ethereum client while transactions are not mined is considered unsafe. We recommend avoiding switching Ethereum clients once the Raiden node is running.</p>
</li>
<li><p><strong>Raiden REST API is never exposed to the public:</strong> For Raiden's operation, the client needs to be able to sign transactions at any point in time. Therefore you should never expose the Raiden Rest API to the public. Be very careful when changing the <code>--api-address</code> and <code>--rpccorsdomain</code> values.</p>
</li>
</ul>
<a href="#try-it-out" id="try-it-out" style="color: inherit; text-decoration: none;">
<h2>Try it out</h2>
</a>
<p>You can install the package from the <a href="https://www.npmjs.com/">NPM registry</a>:</p>
<pre><code class="language-sh"><span style="color: #000000">$ yarn global add @raiden_network/raiden-cli</span>
<span style="color: #000000">$ </span><span style="color: #0000FF">export</span><span style="color: #000000"> PATH=</span><span style="color: #A31515">"$(yarn global bin):</span><span style="color: #001080">$PATH</span><span style="color: #A31515">"</span>
<span style="color: #000000">$ raiden --help</span>
<span style="color: #008000"># or</span>
<span style="color: #000000">$ npm install --global @raiden_network/raiden-cli</span>
<span style="color: #000000">$ raiden --help</span>
</code></pre>
<a href="#aarch64-arm64-environments" id="aarch64-arm64-environments" style="color: inherit; text-decoration: none;">
<h3>Aarch64 (ARM64) environments</h3>
</a>
<p>The Light Client has some development and runtime native libraries as dependencies which may require a proper architecture to work.
In Arm64 processors (e.g. Apple M1 computers) you may want to ensure the following libraries are properly installed for your native architecture:</p>
<pre><code class="language-sh"><span style="color: #000000">$ brew install pkg-config cairo pango libpng jpeg giflib librsvg</span>
</code></pre>
<p>Alternatively, use <a href="https://support.apple.com/en-us/HT211861">Rosetta</a> to switch to a <code>x86_64</code> environment:</p>
<pre><code class="language-sh"><span style="color: #000000">$ arch -x86_64 </span><span style="color: #001080">$SHELL</span>
</code></pre>
<p>Then, ensure NodeJS VM as well as <code>node_modules</code> dependencies are installed for this architecture.</p>
<pre><code class="language-sh"><span style="color: #000000">$ node -p process.arch</span>
<span style="color: #000000">x64</span>
</code></pre>
<a href="#development" id="development" style="color: inherit; text-decoration: none;">
<h2>Development</h2>
</a>
<a href="#build-the-cli" id="build-the-cli" style="color: inherit; text-decoration: none;">
<h3>Build the CLI</h3>
</a>
<pre><code class="language-sh"><span style="color: #000000">yarn install</span>
<span style="color: #000000">yarn workspace raiden-ts build </span><span style="color: #008000"># build local dependency</span>
<span style="color: #000000">yarn workspace @raiden_network/raiden-cli build </span><span style="color: #008000"># build the dependent output</span>
<span style="color: #000000">yarn workspace @raiden_network/raiden-cli build:webui </span><span style="color: #008000"># download and place webUI files</span>
<span style="color: #000000">yarn workspace @raiden_network/raiden-cli build:bundle </span><span style="color: #008000"># build the bundled output; optional</span>
</code></pre>
<p>The <code>build</code> script will output <code>./build/index.js</code>, which requires that the dependencies are in place in the <code>../raiden-ts/node_modules</code>, <code>../raiden-ts/dist*/</code> and <code>./node_modules/</code> folders.
The <code>build:bundle</code> script will output <code>./bundle/index.js</code>, which depends only on <code>*.node</code> native libraries copied to the same output folder, therefore is a portable bundle which can be moved around (as long as the native libraries are in the same folder).</p>
<p>If getting out-of-memory errors, you can build these files on a more capable machine, just be careful to copy the correct native libraries to the output folder if on a different architecture (e.g. copy <code>./node_modules/wrtc/build/Release/wrtc.node</code> to <code>./bundle</code>)</p>
<a href="#run-the-cli" id="run-the-cli" style="color: inherit; text-decoration: none;">
<h3>Run the CLI</h3>
</a>
<p>You can see a summary of the options:</p>
<pre><code class="language-sh"><span style="color: #000000">./raiden --help</span>
</code></pre>
<p>The CLI currently exposes parameters to configure the Raiden node that runs behind the REST service.</p>
<p>Calling it without parameters will run with default options, which include trying to use <code>http://localhost:8545</code> as Ethereum JSON RPC Endpoint, looking for keystore JSONs in <code>./</code> (and showing a selection menu) and storing database in <code>./storage</code>. You probably want to change these options, e.g.:</p>
<pre><code class="language-sh"><span style="color: #000000">./raiden --eth-rpc-endpoint https://goerli.infura.io/v3/YOUR-PROJECT-ID --datadir ~/.raiden --keystore-path ~/.ethereum/goerli/keystore --address 0xYourAddress</span>
</code></pre>
<a href="#documentation" id="documentation" style="color: inherit; text-decoration: none;">
<h3>Documentation</h3>
</a>
<p>The <a href="https://raiden-network.readthedocs.io/en/latest/rest_api.html">Raiden API documentation</a> describes the available API endpoints and provides example requests and responses.</p>
<a href="#custom-options" id="custom-options" style="color: inherit; text-decoration: none;">
<h3>Custom options</h3>
</a>
<p>The CLI diverges slightly (in a compatible manner) from the Python Client REST API above, mostly adding some more information to certain endpoints, new useful endpoints to expose specifics of CLI's internals and command-line parameters for new features, while ignoring certain unsupported parameters from the Python Client's entrypoint command. Here are some notable examples:</p>
<ul>
<li><code>GET|PATCH /api/v1/config</code>: returns the current config of the SDK and allows changing specific options at runtime;</li>
<li><code>GET /api/v1/state.json</code>: returns the state (database) dump, as a JSON array, in real time;</li>
<li><code>--load-state <state.json></code>: command-line option to reload/rehydrate a previous state in a new machine/folder/instance</li>
</ul>
<p>Note: <code>/api/v1/state.json</code> and <code>--load-state</code> are compatible with dApp's State Backup / Upload functionality, allowing one to migrate between one another;
Warning: be sure to not run two instances on the same network and account simultaneously; also, if you ran an instance for any amount of time on another client, you must download and sync the state manually on the other session, as to avoid getting out of sync with the network.</p>
<a href="#contributing" id="contributing" style="color: inherit; text-decoration: none;">
<h2>Contributing</h2>
</a>
<p>Any contributions you make are <strong>greatly appreciated</strong>. Refer to the
<a href="./CONTRIBUTING.md">development guide</a> for details on how to comply with our
codestyle, patterns and quality requirements. Although this is still more
experimental and internal than SDK and dApp, questions and issues can be
reported in the issue tracker.</p>
<a href="#license" id="license" style="color: inherit; text-decoration: none;">
<h2>License</h2>
</a>
<p>Distributed under the <a href="../LICENSE">MIT License</a>.</p>
</div>
</div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<nav class="tsd-navigation primary">
<ul>
<li class="label pp-nav pp-group">
<span>Get <wbr>Started</span>
</li>
<li class=" pp-nav pp-page">
<a href="../Get Started/prerequisites.html">Prerequisites</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Get Started/installing-sdk.html">Installing the SDK</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Get Started/installing-dapp.html">Installing the d<wbr>App</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Get Started/connecting.html">Connecting</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Get Started/private-chain.html">Private chains</a>
</li>
<li class="label pp-nav pp-group">
<span>Usage</span>
</li>
<li class=" pp-nav pp-page">
<a href="../Usage/opening-channel.html">Opening a channel</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Usage/funding-channel.html">Funding a channel</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Usage/direct-transfer.html">Transferring</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Usage/closing-channel.html">Closing a channel</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Usage/settling-channel.html">Settling a channel</a>
</li>
<li class="label pp-nav pp-group">
<span>Using the <wbr>Raiden d<wbr>App</span>
</li>
<li class=" pp-nav pp-page">
<a href="../Using the Raiden dApp/using-dapp.html">Overview</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Using the Raiden dApp/navigate-dapp.html">Navigate the <wbr>Raiden d<wbr>App</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Using the Raiden dApp/hub-selection-channel-opening.html">Hub <wbr>Selection and <wbr>Channel <wbr>Opening</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Using the Raiden dApp/transfers.html">Transfers</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Using the Raiden dApp/channels.html">Channels</a>
</li>
<li class=" pp-nav pp-page">
<a href="../Using the Raiden dApp/account.html">Accounts</a>
</li>
<li class="label pp-nav pp-group">
<span>Using the <wbr>Raiden CLI</span>
</li>
<li class="current pp-nav pp-page">
<a href="README.html">Overview</a>
</li>
<li class=" pp-nav pp-page">
<a href="raspberrypi.html">Running raiden-<wbr>cli on the raspberry pi</a>
</li>
<li class="label pp-nav pp-group">
<span>API</span>
</li>
<li class=" ">
<a href="../../modules.html">Exports</a>
</li>
</ul>
</nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul class="before-current">
</ul>
</nav>
</div>
</div>
</div>
<footer class="with-border-bottom">
<div class="container">
<h2>Legend</h2>
<div class="tsd-legend-group">
<ul class="tsd-legend">
<li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li>
<li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li>
</ul>
<ul class="tsd-legend">
<li class="tsd-kind-property tsd-parent-kind-interface"><span class="tsd-kind-icon">Property</span></li>
<li class="tsd-kind-method tsd-parent-kind-interface"><span class="tsd-kind-icon">Method</span></li>
</ul>
</div>
</div>
</footer>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p>
</div>
<div class="overlay"></div>
<script src="../../assets/js/main.js"></script>
</body>
</html>