# Deployment and Usage of the Raiden Network Smart Contracts¶

## Deploying¶

To deploy the smart contracts use the provided utility script in tools/deploy.py. It expects an unencrypted hex-encoded private key as its only argument. The account of the provided private key needs to hold enough Ether to complete the deployment. At the time of writing a complete deployment requires approximately 5.7 million gas. Example:

python deploy.py --pretty 1111111111111111111111111111111111111111111111111111111111111111


It will output a JSON formatted list of the deployed contracts / libraries addresses. You should keep this for the next steps.

## Using the Contracts¶

It’s possible to have Raiden use other contracts than the default ones configured in raiden/constants.py. To do so use the following command line options:

• --discovery-contract-address corresponds to EndpointRegistry.sol
• --registry-contract-address corresponds to Registry.sol

## Verifying on Etherscan¶

Due to the fact that the Raiden Network uses multiple contracts and libraries verifying them on Etherscan is a bit more involved.

Generally it’s important to use the Contract Version 2.0 verifier. The previous version 1 will not work and produce confusing error messages.

To verify the contract code on Etherscan follow these steps:

1. Enter the Registry’s contract address in the Etherscan search field

2. Click “Contract Code”

3. Modify the URL to verifyContract2 to use the new verification tool

4. Enter the contract name (Registry)

5. Select the used solc version

6. Choose whether the code was compiled using the optimizer. Currently the contracts deployed with the deploy script aren’t optimized.

7. Paste the combined contract code into the provided text area The combined contract code can be generated with the tools/join-contracts.py utility script:

cd raiden/smart_contracts
python ../../tools/join-contracts.py Registry.sol registry-joined.sol

8. Enter ChannelManagerLibrary and its corresponding address into the Library_1 name and address text fields.

9. Click “Verify And Publish”

10. The Registry code should now be verified.

Perform the same steps for the EndpointRegistry, NettingChannelLibrary, and ChannelManagerLibrary contracts except that you don’t need to enter any library addresses.

The ChannelManagerContract and NettingChannelContract contracts only get deployed once a token has been added and a channel has been opened.

The easiest way to do so is to start raiden using the new contracts (see. Using the contracts above) and then follow these steps:

1. Register a token. For example the RTT token:

curl -X PUT http://localhost:5001/api/1/tokens/0x0f114A1E9Db192502E7856309cc899952b3db1ED


The call will return the channel manager address. You can use this to verify the contract. To do so follow the same steps as before except this time use:

1. ChannelManagerContract as the contract name

2. Use the joined code from ChannelManagerContract.sol

3. You need to provide the constructor arguments that were used to deploy the contract

4. In this case this is just the token address. To get the right format you can use pyethereum’s encode_abi function. For example:

>>> from ethereum.abi import encode_abi
'0000000000000000000000000f114a1e9db192502e7856309cc899952b3db1ed'

5. Place the output from the above call into the “Constructor Arguments” field

6. Enter ChannelManagerLibrary and its corresponding address into the Library_1 name and address text fields.

7. The ChannelManagerContract is now verified

Similarly the NettingChannelContract also is only deployed once a channel has been opened. Again this can be accomplished by using the following command:

curl -X PUT -H "Content-Type: application/json" \
http://localhost:5001/api/1/channels \
-d '{"partner_address": "0x2222222222222222222222222222222222222222", "token_address": "0x0f114A1E9Db192502E7856309cc899952b3db1ED", "balance": 1}'


The call will return the information of the newly created channel. The important one for our purposes is the channel_address. This is the address of a deployed NettingChannelContract. To verify it follow the same steps as before except:

1. Use NettingChannelContract as the name

2. Use the joined code from NettingChannelContract.sol

3. Encode the constructor arguments as before. The arguments are: token_address, own_address, partner_address, settle_timeout:

>>> from ethereum.abi import encode_abi
>>> encode_abi(

5. Enter NettingChannelLibrary and its corresponding address into the Library_1 name and address text fields.