{"id":20057703,"url":"https://github.com/raiden-network/raiden-contracts","last_synced_at":"2025-04-13T08:24:18.700Z","repository":{"id":37617436,"uuid":"123951681","full_name":"raiden-network/raiden-contracts","owner":"raiden-network","description":"Raiden Network Smart Contracts","archived":false,"fork":false,"pushed_at":"2023-03-07T23:59:16.000Z","size":8795,"stargazers_count":54,"open_issues_count":168,"forks_count":45,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-13T08:23:45.970Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raiden-network.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-05T17:06:47.000Z","updated_at":"2025-03-13T13:46:29.000Z","dependencies_parsed_at":"2024-06-19T01:24:24.775Z","dependency_job_id":"fd5c7764-19dd-4207-843d-2572c59dd5d3","html_url":"https://github.com/raiden-network/raiden-contracts","commit_stats":{"total_commits":2090,"total_committers":29,"mean_commits":72.06896551724138,"dds":0.5047846889952153,"last_synced_commit":"ce3d253cc5fbbedbb878a4f8722008ac954aeea3"},"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiden-network%2Fraiden-contracts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiden-network%2Fraiden-contracts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiden-network%2Fraiden-contracts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiden-network%2Fraiden-contracts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raiden-network","download_url":"https://codeload.github.com/raiden-network/raiden-contracts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248682153,"owners_count":21144805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T12:59:58.699Z","updated_at":"2025-04-13T08:24:18.663Z","avatar_url":"https://github.com/raiden-network.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"Raiden Network Smart Contracts\n==============================\n\n.. image:: https://badges.gitter.im/Join%20Chat.svg\n    :target: https://gitter.im/raiden-network/raiden?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\n    :alt: Chat on Gitter\n\n`Raiden Network Smart Contract specs`_\n\n.. _Raiden Network Smart Contract specs: https://raiden-network-specification.readthedocs.io/en/latest/smart_contracts.html\n\nPrerequisites\n-------------\n\n-  Python 3.8 or 3.9\n-  https://pip.pypa.io/en/stable/\n\nInstallation\n------------\n\nRecommended::\n\n    pip install raiden-contracts\n\n\nFinding Deployed Contract Instances\n-----------------------------------\n\nAll smart contracts in this repository are made available WITHOUT ANY\nREPRESENTATION OR WARRANTY; without even the (implied) warranty of FITNESS FOR\nANY PARTICULAR PURPOSE. Use at your own risk.\n\nIf you want to use the deployed contracts, please use the\n``raiden_contracts/data_\u003cCONTRACTS_VERSION\u003e/contracts.json`` file to get the ABI\nand bytecode for initializing the contract instances.\n\nYou can find the addresses of the deployed contracts in\n``raiden_contracts/data_\u003cCONTRACTS_VERSION\u003e/deployment_*.json``. All contracts\nunder ``raiden_contracts/contracts/test/`` are only for testing purposes and\nthey should not be used in production.\n\nYou can find other useful constants that you can import in\n``raiden_contracts/constants.py``.\n\n.. Note::\n    This package supports many contract versions, including:\n\n    * Development ``0.3._`` contracts version (from ``0.3.0`` package release: https://github.com/raiden-network/raiden-contracts/releases/tag/v0.3.0). No limits on the number of tokens registered; has a limit of 100 tokens per channel). Source code: https://github.com/raiden-network/raiden-contracts/tree/fc1c79329a165c738fc55c3505cf801cc79872e4/raiden_contracts/contracts\n    * Red Eyes Mainnet ``0.4.0`` contracts version (from ``0.7.0`` package release: https://github.com/raiden-network/raiden-contracts/releases/tag/v0.7.0). Source code: https://github.com/raiden-network/raiden-contracts/tree/fac73623d5b92b7c070fdde2b446648ec9117474/raiden_contracts/contracts\n    * current !development version corresponding with the ``master`` branch (might not be stable).\n\n    The current policy is to add all new deployment data together with the sources.\n\nIf you want to use the officially deployed contracts, please use the\n``raiden_contracts/data_\u003cCONTRACTS_VERSION\u003e`` files to get the precompiled data\n(ABI, bytecode etc.) and addresses for initializing the contract instances.\nAlternatively, in Python scripts, with ``raiden-contracts`` package, you can\nfind the already deployed contract instances like::\n\n    from raiden_contracts.contract_manager import (\n        ContractManager,\n        contracts_precompiled_path,\n        get_contracts_deployment_info,\n    )\n    from raiden_contracts.constants import (\n        CONTRACT_TOKEN_NETWORK_REGISTRY,\n        CONTRACT_MONITORING_SERVICE,\n        CONTRACTS_VERSION,\n        EVENT_TOKEN_NETWORK_CREATED,\n    )\n\n    # ``raiden-contracts`` provides ``contracts_version``s like\n    # ``0.9.0``, ``'0.4.0'`` and ``'0.3._'``.  They are explained below.\n\n    # Uses the newest test net release available on Kovan, Rinkeby and Ropsten.\n    contracts_version = CONTRACTS_VERSION\n\n    # Uses Red Eyes, Mainnet enabled version with deposit limits.\n    # The version is also available on Kovan, Rinkeby and Ropsten.\n    contracts_version = '0.4.0'\n\n    # Uses the pre-red-eyes development version, probably without\n    # deposit limits. Available only on Kovan, Rinkeby and Ropsten.\n    # The Solidity source of this version is unknown on Etherscan.\n    # See https://github.com/raiden-network/raiden-contracts/issues/543\n    contracts_version = '0.3._'\n\n    manager = ContractManager(contracts_precompiled_path(contracts_version))\n    compiled_contract_data = manager.get_contract(CONTRACT_TOKEN_NETWORK_REGISTRY)\n\n    deployment_data = get_contracts_deployment_info(web3.eth.chainId)\n    TOKEN_NETWORK_REGISTRY_ADDRESS = deployment_data['contracts'][CONTRACT_TOKEN_NETWORK_REGISTRY][\"address\"]\n\n    # And then use:\n    # compiled_contract_data['abi']\n    # compiled_contract_data['bin']\n    # TOKEN_NETWORK_REGISTRY_ADDRESS\n    # to initialize the contract instance\n\n    # To use one of the 3rd party services contracts:\n    compiled_ms_contract = manager.get_contract(CONTRACT_MONITORING_SERVICE)\n    MONITORING_SERVICE_ADDRESS = deployment_data['contracts'][CONTRACT_MONITORING_SERVICE][\"address\"]\n\nLooking Up Gas Consumption\n--------------------------\n\nEach ``contracts_version`` (at least ``0.8.0``) comes with gas consumption measurements::\n\n    gas = gas_measurements(contracts_version)\n    gas[\"TokenNetwork.setTotalDeposit\"]\n\nevaluates to something like 45000.\n\n\nTest-only Contracts\n-------------------\n\nAll contracts under ``raiden_contracts/contracts/test/`` are only for testing purposes and they should not be used in production.\n\nDevelopment\n-----------\n\nIf you want to test and further develop outside the officially provided source code, compiled files and deployed addresses, you can do it at your own risk.\n\n\nIf you want to install the package from source::\n\n    make install-dev\n\nTo verify that the precompiled ``raiden_contracts/data/contracts.json`` file corresponds to the source code of the contracts::\n\n    make verify_contracts\n\n\nCompile the contracts\n^^^^^^^^^^^^^^^^^^^^^\n\nNeeded if you have made changes to the source code.\n\n::\n\n    make compile_contracts\n\n\nUpdating gas costs\n^^^^^^^^^^^^^^^^^^\n\nTo update the gas costs run\n\n::\n\n    make update_gas_costs\n\n\nTesting\n^^^^^^^\n\nIf you want to write tests, check `/raiden_contracts/tests/README.md` first.\n\n::\n\n    # tests\n    pytest\n    pytest raiden_contracts/tests/test_token_network.py\n\n    # Recommended for speed:\n    pip install pytest-xdist==1.17.1\n    pytest -n NUM_OF_CPUs\n\n\nIf you are using the ``raiden-contracts`` package in your project, you can also test the source code directly (not only the precompiled contract data)::\n\n    from raiden_contracts.contract_manager import (\n        ContractManager,\n        contracts_source_path,\n    )\n\n    manager = ContractManager(contracts_source_path(\u003cCONTRACTS_VERSION\u003e))\n\n\nDeployment on a testnet\n-----------------------\n\n- get the source code from the latest stable release\n- install development dependencies::\n\n    pip install -r requirements-dev.txt\n\n.. Note::\n    If deploying on your own private chain, you need to start ``geth`` with ``--networkid \u003cchainID_from_genesis.json\u003e``. The private chain must be running the Byzantium protocol (or a later version) at the time of deployment.\n\n    If you want to use a particular version of the contracts that is supported, you can use the ``deploy`` script with ``-- contracts-version \"0.4.0\"``.\n\nCheck deployment options::\n\n    python -m raiden_contracts.deploy --help\n\nDeploying the main Raiden Network contracts with the ``raiden`` command::\n\n    python -m raiden_contracts.deploy raiden --rpc-provider http://127.0.0.1:8545 --private-key /path/to/your/private_key/file --gas-price 10 --gas-limit 6000000 --max-token-networks 1\n\nWhen the ``raiden`` command is passed the optional argument ``--secret-registry-from-deployment-file \u003cdeployment-file\u003e``, the command tries to reuse ``SecretRegistry`` instance found in ``\u003cdeployment-file\u003e``.  For example, some deployment files are found under ``raiden_contracts/data*/deployment_*.json``.\n\nDeploying the mock token contract for paying for the services (not to be done on the mainnet)::\n\n    python -m raiden_contracts.deploy token --rpc-provider http://127.0.0.1:8545 --private-key /path/to/your/private_key/file --gas-price 10 --token-supply 20000000 --token-name ServiceToken --token-decimals 18 --token-symbol SVT\n\nDeploying the 3rd party service contracts with the ``services`` command::\n\n    python -m raiden_contracts.deploy services --rpc-provider http://127.0.0.1:8545 --private-key /path/to/your/private_key/file --gas-price 10 --gas-limit 6000000 --token-address TOKEN_USED_TO_PAY_SERVICES --user-deposit-whole-limit MAX_TOTAL_AMOUNT_OF_TOKENS_DEPOSITED_IN_USER_DEPOSIT --service-deposit-bump-numerator NUMERATOR_OF_PRICE_DUMP --service-deposit-bump-denominator DENOMINATOR_OF_PRICE_DUMP --service-deposit-decay-constant DECAY_CONSTANT --initial-service-deposit-price INITIAL_PRICE --service-deposit-min-price MIN_PRICE --service-registration-duration REGISTRATION_DURATION_IN_SECS --token-network-registry-address TOKEN_NETWORK_REGISTRY_ADDRESS\n\nWhen the ``services`` command is passed the optional argument ``--service-registry-from-deployment-file \u003cdeployment-file\u003e``, the command tries to reuse ``ServiceRegistry`` instance found in ``\u003cdeployment-file\u003e``.  For example, some deployment files are found under ``raiden_contracts/data*/deployment_*.json``.\n\nDeploying a token for testing purposes (please DO NOT use this for production purposes) with the ``token`` command::\n\n    python -m raiden_contracts.deploy token --rpc-provider http://127.0.0.1:8545 --private-key /path/to/your/private_key/file --gas-price 10 --token-supply 10000000 --token-name TestToken --token-decimals 18 --token-symbol TTT\n\nRegistering a token with the ``TokenNetworkRegistry`` contract, so it can be used by the Raiden Network, with the ``register`` command::\n\n    python -m raiden_contracts.deploy register --rpc-provider http://127.0.0.1:8545 --private-key /path/to/your/private_key/file --gas-price 10 --token-address TOKEN_TO_BE_REGISTERED_ADDRESS --token-network-registry-address TOKEN_NETWORK_REGISTRY_ADDRESS --channel-participant-deposit-limit 115792089237316195423570985008687907853269984665640564039457584007913129639935 --token-network-deposit-limit 115792089237316195423570985008687907853269984665640564039457584007913129639935\n\n.. Note::\n    Registering a token only works once. All subsequent transactions will fail.\n\nDeployment information is stored in a ``deployment_[CHAIN_NAME].json`` file corresponding to the chain on which it was deployed. To verify that the deployed contracts match the compiled data in ``contracts.json`` and also match the deployment information in the file, we can run:\n\n::\n\n    python -m raiden_contracts.deploy verify --rpc-provider http://127.0.0.1:8545\n\n    # Based on the network id, the script verifies the corresponding deployment_[CHAIN_NAME].json file\n    # using the chain name-id mapping from constants.py\n\nDeployment on an Arbitrum based network\n-----------------------\n\nIn case the target network is based on Arbitrum, it needs some extra care in terms of the gas. Gas works differently here and therefore the associated commandline parameter requires different values. First of all the ``--gas-limit`` parameter should not be set. This gets done automatically and in adaption to Arbitrum. Second, the ``--gas-price`` parameter has a different effect. On Arbitrum this defines the highest price the transactor is willing to pay. This means up-on execution the Arbitrum node will reduce the price automatically to the current price and no more. So this can be seen as ``--max-gas-price``. The amount has no impact on how fast the transaction gets through. The default `5 Gwei` should be enough for most cases. To be sure, just check the current gas price on an official Arbitrum block explorer. In case the value is too low, the Arbitrum node will just reject the transaction with a respective error message.\n\n\nVerification with Etherscan\n^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n::\n\n    python -m raiden_contracts.deploy.etherscan_verify --apikey ETHERSCAN_APIKEY --chain-id 3\n\nIf the command exists with status code 0, Etherscan has verified all contracts against Solidity sources.\n\n\nUtilities for minting, balance checking, token transfer\n-------------------------------------------------------\nYou can mint tokens from a CustomToken contract, WETH contract from any testnet\nand query balances from the commandline using the ``token_ops.py``\nSample usage\n\n* Minting tokens ::\n\n   python token_ops.py mint --rpc-url http://127.0.0.1:8545 --private-key ~/priv_chain/blkchain1/keystore/private_net_address --token-address 0x2feEd0E54238051dddCc01bF3960B143e887a9B7 --amount 1000\n\n* Minting tokens with a password file ::\n\n   python token_ops.py mint --rpc-url https://rpc.slock.it/goerli --private-key ~/.ethereum/keystore/UTC--2019-04-25T07-10-37.872928741Z--f8608ad00ab66b3a2aa21253c7915413034d0be5 --password ~/.ethereum/keystore/passwd_F8608A.txt --token-address 0x610f3c3C1998FAd6A659A9f5Bb83962DA27eAf1d --amount 1000\n\n* Getting weth tokens ::\n\n   python token_ops.py weth --rpc-url http://127.0.0.1:8545 --private-key ~/priv_chain/blkchain1/keystore/private_net_address --token-address 0xdf048aa8cbA44f9590F888BAb5e5AC78AAb503C8 --amount 1000\n\n* Query account balance in any token ::\n\n   python token_ops.py balance --rpc-url http://127.0.0.1:8545 --token-address 0xdf048aa8cbA44f9590F888BAb5e5AC78AAb503C8 --address 0xb8eb60F2E45667c9B2cFf861b82656452659C6dE\n\n* Transfer tokens ::\n\n   python token_ops.py transfer --rpc-url http://127.0.0.1:8545 --private-key ~/priv_chain/blkchain1/keystore/private_net_address --token-address 0xdf048aa8cbA44f9590F888BAb5e5AC78AAb503C8 --amount 1000 --destination 0x7ba5f1c08548f80d52856c21e87fcca05c5e40e3\n\n\nMaking a Release\n----------------\n\nSee `Release Process Document`_.\n\n.. _Release Process Document: RELEASE.rst\n\n\nDirectory Structure\n-------------------\n\n- `raiden_contracts`\n    - `contracts`\n        - `lib` - libraries used by core contracts\n        - `services` - contains 3rd party services contracts\n        - `test` - test contracts used to test core contracts\n        - raiden core contracts files\n    - `data` - compiled contracts data \u0026 deployment information\n    - `data_0.3._` - compiled contracts data \u0026 deployment information for an older version with only a channel limit of 100 tokens\n    - `data_0.4.0` - compiled contracts data \u0026 deployment information for Red Eyes release\n    - `data_0.x.y` - compiled contracts data \u0026 deployment information only for test nets\n    - `deploy` - deployment \u0026 verification scripts\n    - `tests`\n        - `fixtures` - fixtures used by all tests\n        - `property` - property tests for core contracts\n        - `unit` - unit tests for internal functions in core contracts\n        - `utils` - specific utilities for tests, closely related to the contracts logic\n        - main test files for both core \u0026 service contracts\n    - `utils`\n        - general utilities for tests (signing, merkle trees, logs), independent of the contracts logic\n        - some utilities related to the contracts logic that might be exported by projects using the package\n    - `constants.py` - package deliverable, constants used by projects that import the package\n    - `contract_manager.py` - package deliverable, used by projects that import the package, gets the correct compiled contracts data based on version\n- setup files for requirements, builds etc.\n\n\nFAQ\n---\n\nWhy am I seeing many version numbers?\n  You are seeing a version number of the PyPI package and several version numbers of smart contract sources.  This same PyPI package provides access to multiple deployments of smart contracts. People use ``raiden-contracts`` PyPI package to interact with a mainnet deployment made a while ago, an older testnet deployment without deposit limits, or a newer testnet deployment with deposit limits and with service contracts.\n\nWhy does the same package provide different versions of smart contracts?\n  Because a prominent user (``raiden``) uses a single version of this package. They might one day start using multiple TokenNetwork deployments from multiple contracts versions.\n\nAre the package version and the smart contracts versions related?\n  Yes, especially since package version 0.33.3. Whenever there is a new contracts version, the package version and the contracts version get a minor upgrade (Y increases in 0.Y.Z), and they look similar. When a package upgrade only contains Python changes, the package version only gets a patch upgrade (Z increases in 0.Y.Z).\n\nHow to find the addresses of deployed contracts?\n  Search above for ``get_contracts_deployed`` and see the usage.\n\nHow to mint the tokens on the test network?\n  Each contract that receives a token has a public variable ``Token public token``.  On the test networks, they might be `CustomToken contract \u003chttps://github.com/raiden-network/raiden-contracts/blob/59631b6c8b7bcb0b9a3accdf1fb41082c29dcaa1/raiden_contracts/data/source/test/CustomToken.sol\u003e`__ so you can call ``mint(how_many)`` function of the CustomToken contract to get some new tokens.\n\nI see ``block gas exceeded``\n  Perhaps you've added ``--gas-limit`` option with a too big integer. Try dropping the option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraiden-network%2Fraiden-contracts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraiden-network%2Fraiden-contracts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraiden-network%2Fraiden-contracts/lists"}