Join a Token Network

To be able to make token payments in Raiden you first need to join the network of the token you're interested in making payments with.

Check if the token is registered

Before you can join a token network you need to determine whether the token has been registered and a network for the token has been created.

We can verify this by making a query to the tokens endpoint.

curl -i http://localhost:5001/api/v1/tokens

If the address exists in the list returned by the response you can go ahead and join the already existing token network.

If the address is not in the list you'll have to register the token before joining its network.

Register a new token and join its network

Registering a new token is as simple as calling the tokens endpoint with a PUT request while providing the address of the token you want to register as a path parameter.

curl -i -X PUT http://localhost:5001/api/v1/tokens/0x9aBa529db3FF2D8409A1da4C9eB148879b046700 \
-H 'Content-Type: application/json'

If the call is successful the response will return a new address of the now newly created token network.

Content-Type: application/json
"token_network_address": "0xC4F8393fb7971E8B299bC1b302F85BfFB3a1275a"

Because this token was just registered by you, no one else will be connected to its network and you'll have to open a channel with another Raiden node.

Payment channels between parties are opened in token networks.

Registering a new token is currently only relevant on the testnets. The tokens allowed on the mainnet for the Alderaan release are DAI and W-ETH. At some point in future, you will be able to register new token networks for the Ethereum mainnet, too.

Join an existing token network

Joining the network of a token that has already been registered is the most common way of connecting to a token network.

For this, the connections endpoint with a PUT request can be used and all you need to provide is:

  1. The address of the token which network you want to join as a path parameter.

  2. The amount of tokens you want to deposit in the channel as a body parameter.

curl -i -X PUT http://localhost:5001/api/v1/connections/0x9aBa529db3FF2D8409A1da4C9eB148879b046700 \
-H 'Content-Type: application/json' \
--data-raw '{"funds": "2000"}'

In its current implementation the connection manager that is used for opening channels might also connect you with nodes that happen to be offline.

That won't be much of a help for sending payments. So if you already know the address of a node you'd like to send payments to you can join the token network by opening a channel directly with that node.

In the example above we'll assume a connection was successfully made to the network of token 0x9aBa529db3FF2D8409A1da4C9eB148879b046700 by depositing 2000 tokens.

Three channels were also automatically opened with three random nodes and 20% of the 2000 tokens were deposited in each channel with the remaining 40% reserved for whenever you want to open a channel with another node or top up a channel.

Your node should now be well connected and you can jump ahead and start making payments. If you want, you could also choose to open a channel with a friend's node.