Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
First Raiden Transaction
documentation for latest release notes.31-09-2017: THIS IS VERY OUTDATED. Please see the
Raiden is a payment channel implementation which provides scalable, low latency, and cheap token transfers for Ethereum.
Our team has just finished the first proof of concept version which implements a working core of Raiden. It enables off-chain transfers of any ERC-20 based token using a network of payment channels. The opening, closing and settlement of channels take place on the Ethereum blockchain.
The first transaction was sending tokens from a Raiden client in Copenhagen to one in Mumbai mediated by a node in Florianópolis. The opening, closing, and settlement of channels took place on the Ethereum testnet, while the actual transfers happened off-chain. You can see the involved on-chain transactions here:
This PoC was the first in a series of milestones leading to a beta version scheduled for Q4/2016.
We would like to thank Omise, our partners in the Asia-Pacific region, for their support in enabling the development of Raiden at its earliest stage. We would also like to thank Wanxiang Blockchain Labs for their generous grant which further aided the process. brainbot technologies would also like to thank its development team for their hard work to deliver this milestone.
If you have any questions, please join our gitter channel.
Getting started with Raiden
06/2017: Please note that this is outdated. Newer instructions are to be expected with the upcoming Developer Preview release.
Even though the current milestone implements the core features of the system, it is still in its infancy, i.e., not production ready. Nonetheless, below we describe how to setup Raiden and facilitate transfers as a starting point for curious developers.
You will need to have some system dependencies installed:
If you want to try out Raiden you can follow these steps:
git clone https://github.com/raiden-network/raiden.git
As always it's advised to create a new
virtualenv to run Raiden in.
Install the requirements:
pip install -e .
From here tests can be found in
After you have cloned Raiden you can start it with the following command:
raiden --external-listen-address <yourExternalIP>:<yourForwardingPORT>
Note: there will be some other parameters set per default, such as:
--eth-rpc-endpoint 127.0.0.1:8545the rpc-endpoint of your ethereum client
--listen-address 0.0.0.0:40001the local listen address for your raiden node
--registry-contract-address 07d153249abe665be6ca49999952c7023abb5169points to the deployed contract on the morden testnet
--discovery-contract-adress 1376c0c3e876ed042df42320d8a554a51c8c8a87points to the deployed contract on the morden testnet
This will prompt for the private key corresponding to the account you are using on the test net. Provide it, and you are ready to go
The Raiden console
When you're in the Raiden console, to open a channel and make a transfer, complete the following steps:
Add the token you want to transfer in the payment channel
token_address = 'address of the token you want to add without leading 0x'
or if you want to create your own token
token_address = tools.create_token(initial_alloc=1000, name="mytoken", symbol="MT", decimals=2)
Specify the address of the node you want to interact with. This could be a second local node of your own or a fellow Ethereum enthusiast. Let's assume, for the sake of simplicity, that your name is Alice and your channel partner's name is Bob (if you're short of a partner to play around with, you can ask for peers in our gitter channel!)
bob = 'address of partner without leading 0x'
Make sure, you and your peer are able to ping each other:
If the network settings are correct, this should return
True. Bob should do the same.
Open a channel with Bob (your account must have at least the
amountas balance of the transferred token)
tools.open_channel_with_funding(token_address, bob, amount)
(optional) Bob can deposit to the channel. He must have some tokens in order to deposit. Alice represents your address.
raiden.api.deposit(token_address, alice, amount)
Make a transfer(s). Feel free to make as many as you want, and in both directions.
Alice -> Bob
raiden.api.transfer(token_address, 73, bob)
raiden.api.transfer(token_address, 42, bob)
optional: Bob -> Alice
raiden.api.transfer(token_address, 50, alice)
Check the state of the channel. This will give you an excellent overview of the channel, where you can see funding, balances, etc.
tools.channel_stats_for(token_address, bob, pretty=True)
Once you're satisfied with the amount of transfers you've carried out, you can close the channel
In order for the channel to pay out, it must be settled. This can be done ten blocks after the channel has been closed. This timeout exists so that nodes can provide more up to date transfers if a partner node tries to cheat.
You will now see that your balance of the token has changed or check that Bob's balance changed.
You've now performed your first Raiden transfer. Congratulations! Albeit a pretty boring direct transfer. Raiden really gets interesting when doing mediated transfers. This is possible with node channels in the system that form a connected graph. An example of this could be if Alice had a channel with Bob, and Bob had a channel with Charlie. Both channels handle the same token. Alice could then create a transfer to Charlie without having an open channel to Charlie. This is possible since the transfer is mediated through Bob, which both, Alice and Charlie, have a channel with.
Feel free to play around, create more transfers, etc., but be advised that this version of the smart contract does not allow you to open a channel with the same partner and asset after it's been closed.
At this point, there is no battle tested NAT-punching mechanism implemented. That means that you need to open up and forward a port for your raiden node manually. The forwarding should point to your
listen_address which is your computers LAN-IP and the port 40001 per default.
However, there is an experimental UPnP NAT-port mapper. If you don't have access to your router, and you're lucky, you can use these steps to request a NAT port mapping via UPnP and update the
discovery manually, once you are in the Raiden console:
# install requirement %sx pip install miniupnpc from raiden.network import nat external_ip, external_port = nat.open_port(40001) # the portnumber from `--listen-address` # if this doesn't throw an error: print external_ip, external_port # see if this looks reasonable # now update the discovery contract: discovery.register(raiden.address.encode('hex'), external_ip, external_port)
Now ask your peer to
tools.ping(<your raiden address>).
external-listen-address should point to your public IP address and the external port you forwarded. A quick way to get your public IP-address is the command:
If you don't know how to retrieve your private key here's one way to do it:
# ipython ... In : import json In : from pyethapp.accounts import Account In : with open('<path/to/keystore/and/keyfile>') as f: keyfile = json.load(f) In : account = Account(keyfile) In : account.unlock('yourpassword') In : account._privkey.encode('hex') Out: '0123........abcdef' # your privatekey, paste this on the `raiden` prompt when asked for 'Privatekey'
There is the
tool object in the
raiden client, that helps you to mint a new token for yourself and your peers:
tools.create_token? will show you the parameters for token creation. E.g.:
token_address = tools.create_token(initial_alloc=1000, name="mytoken", symbol="MT", decimals=2) asset = raiden.chain.asset(token_address.decode('hex')) asset.proxy.transfer(bob, 100)