Raiden RPC
A module for interacting with a Raiden network node over RPC.
Installation
npm install raiden-rpc
Example
Require the library
var RaidenClient = require('raiden-rpc');
Create a new raiden instance for a specific node. See below for possible options.
// Quick localhost development
var localNode = RaidenClient.localNode(); // Uses DEFAULT_RPC_HOST
// Custom hostname
var myNode = new RaidenClient('http://192.168.1.124:5004');
Join a token network and transfer tokens to another node
const testnetToken = '0x0f114a1e9db192502e7856309cc899952b3db1ed';
const recipientAddress = '0x61c808d82a3ac53231750dadc13c777b59310bd9';
// Retrieve our own address as sanity check
myNode.getAddress()
// Deposit 100 testnet tokens, 20 amongst 3 channels, 40 reserved for future channels
.then(myAddress => myNode.joinNetwork(testnetToken, 100, 3, 0.4))
// Promise resolves after all channels opened
// Send 8 tokens to recipient with transfer ID 1337
.then(() => myNode.sendTokens(testnetToken, recipientAddress, 8, 1337))
// Promise resolves after transfer succeeds or fails
// Leave the token network
.then(() => myNode.leaveNetwork(testnetToken));
Overview
-
raiden-rpc
-
RaidenClient
⏏ - new RaidenClient([rpcHost], [apiVersion])
-
instance
- .customRequest(method, uri, [...options])
-
.getAddress([options]) ⇒
Promise
-
.registerToken(tokenAddress, [options]) ⇒
Promise
-
.getRegisteredTokens([options]) ⇒
Promise
-
.getTokenPartners(tokenAddress, [options]) ⇒
Promise
-
.getChannel(channelAddress, [options]) ⇒
Promise
-
.getAllChannels([options]) ⇒
Promise
-
.openChannel(partnerAddress, tokenAddress, initialBalance, [settleTimeout], [revealTimeout], [options]) ⇒
Promise
-
.closeChannel(channelAddress, [options]) ⇒
Promise
-
.settleChannel(channelAddress, [options]) ⇒
Promise
-
.deposit(channelAddress, amount, [options]) ⇒
Promise
-
.joinNetwork(tokenAddress, depositAmount, [numberOfChannels], [reserveDepositRatio], [options]) ⇒
Promise
-
.leaveNetwork(tokenAddress, [onlyReceivingChannels], [options]) ⇒
Promise
-
.sendTokens(tokenAddress, recipientAddress, amount, [transferId], [options]) ⇒
Promise
-
.makeTokenSwap(tokenSwap, [options]) ⇒
Promise
-
.takeTokenSwap(tokenSwap, [options]) ⇒
Promise
-
.getNetworkEvents([fromBlock], [options]) ⇒
Promise
-
.getTokenEvents(tokenAddress, [fromBlock], [options]) ⇒
Promise
-
.getChannelEvents(channelAddress, [fromBlock], [options]) ⇒
Promise
-
static
-
.localNode() ⇒
Raiden
-
.localNode() ⇒
-
inner
-
~DEFAULT_RPC_HOST :
String
-
~DEFAULT_RPC_HOST :
-
RaidenClient