{"id":13407305,"url":"https://github.com/raiden-network/microraiden","last_synced_at":"2025-03-14T11:31:20.184Z","repository":{"id":57441530,"uuid":"99348649","full_name":"raiden-network/microraiden","owner":"raiden-network","description":null,"archived":true,"fork":false,"pushed_at":"2018-08-22T12:13:33.000Z","size":16556,"stargazers_count":361,"open_issues_count":49,"forks_count":101,"subscribers_count":58,"default_branch":"master","last_synced_at":"2025-03-11T01:47:00.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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.md","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}},"created_at":"2017-08-04T14:04:29.000Z","updated_at":"2024-04-17T09:44:50.000Z","dependencies_parsed_at":"2022-09-06T02:40:32.928Z","dependency_job_id":null,"html_url":"https://github.com/raiden-network/microraiden","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiden-network%2Fmicroraiden","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiden-network%2Fmicroraiden/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiden-network%2Fmicroraiden/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raiden-network%2Fmicroraiden/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raiden-network","download_url":"https://codeload.github.com/raiden-network/microraiden/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243569460,"owners_count":20312431,"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-07-30T20:00:35.961Z","updated_at":"2025-03-14T11:31:15.525Z","avatar_url":"https://github.com/raiden-network.png","language":"JavaScript","funding_links":[],"categories":["MicroRaiden","Raiden Network","⚡ MicroRaiden"],"sub_categories":["Community Channels","Product/Document"],"readme":"# µRaiden [![Build Status](https://api.travis-ci.org/raiden-network/microraiden.svg)](https://travis-ci.org/raiden-network/microraiden)\n\n[![Join the chat at https://gitter.im/raiden-network/microraiden](https://badges.gitter.im/raiden-network/microraiden.svg)](https://gitter.im/raiden-network/microraiden?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n\nµRaiden is an off-chain, cheap, scalable and low-latency micropayment solution.\n\n[µRaiden documentation](https://microraiden.readthedocs.io/)\n\n\n## Smart Contract\n\nCurrent version: `0.2.0` (second Bug Bounty release). Verifiable with `RaidenMicroTransferChannels.call().version()`.\nNote that a new µRaiden release might include changing the Ethereum address used for the smart contract, in case we need to deploy an improved contract version.\n\nThe `RaidenMicroTransferChannels` contract has been deployed on the main net: [0x1440317CB15499083dEE3dDf49C2bD51D0d92e33](https://etherscan.io/address/0x1440317CB15499083dEE3dDf49C2bD51D0d92e33)\n\nThe following parameters were used:\n- `token_address`: `0x255aa6df07540cb5d3d297f0d0d4d84cb52bc8e6`\n- `challenge_period`: `8640` (blocks, rough equivalent of 36 hours)\n\n\nThere have been internal and external audits of the above contract. That being said, we do not recommend them to be used in production before a stable `1.0.0` release is made. All contracts are WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use at your own risk.\n\nA stable release depends on the [SignTypedData - EIP712](https://github.com/ethereum/EIPs/pull/712) standard being finalized. We are aware that the current supported implementation of this standard has security issues.\n\n\n### Kovan\n\n\n- CustomToken address is:  [0xb5fdb634904ebe09196c506a4cc4250202f0988f](https://kovan.etherscan.io/address/0xb5fdb634904ebe09196c506a4cc4250202f0988f)\n- RaidenMicroTransferChannels address is: [0xed94e711e9de1ff1e7dd34c39f0d4338a6a6ef92](https://kovan.etherscan.io/address/0xed94e711e9de1ff1e7dd34c39f0d4338a6a6ef92#code)\n\n\n### Ropsten\n\n- CustomToken address is:  [0xff24d15afb9eb080c089053be99881dd18aa1090](https://ropsten.etherscan.io/address/0xff24d15afb9eb080c089053be99881dd18aa1090)\n- RaidenMicroTransferChannels address is: [0x74434527b8e6c8296506d61d0faf3d18c9e4649a](https://ropsten.etherscan.io/address/0x74434527b8e6c8296506d61d0faf3d18c9e4649a#code)\n\n\n### Rinkeby\n\n- CustomToken address is:  [0xf0f863ca785047075f6a92d28fd7dee4de47895e](https://rinkeby.etherscan.io/address/0xf0f863ca785047075f6a92d28fd7dee4de47895e)\n- RaidenMicroTransferChannels address is: [0xbec8fb898e6da01152576d1a1acdd2c957e56fb1](https://rinkeby.etherscan.io/address/0xbec8fb898e6da01152576d1a1acdd2c957e56fb1#code)\n\n\n## Brief Overview\n\nµRaiden is not part of the [Raiden Network](https://github.com/raiden-network/raiden). However, it was built using the same state channel idea and implements it in a less general fashion focusing on the concrete application of micropayments for paywalled content.\n\nThe main differences between the Raiden Network and µRaiden are:\n * µRaiden is a many-to-one unidirectional state channel protocol, while the Raiden Network is a many-to-many bidirectional solution and implies a more complex design of channel networks. This allows the Raiden Network to efficiently send transfers without being forced to pay for opening new channels with people who are already in the network.\n * µRaiden off-chain transactions do not cost anything, as they are only exchanged between sender and receiver. The Raiden Network has a more complicated incentive-based off-chain transport of transaction information, from one user to another (following the channel network path used to connect the sender and the receiver).\n\n\n### Tokens and Channel Manager Contract\n\nµRaiden uses its own token for payments which is both [ERC20](https://github.com/ethereum/EIPs/issues/20) and [ERC223](https://github.com/ethereum/EIPs/issues/223) compliant.\n\nIn a nutshell, clients (subsequently called \"senders\") wanting to access a provider's payable resources, will [open a micropayment channel](http://microraiden.readthedocs.io/en/latest/contract/index.html#opening-a-transfer-channel) with the provider (\"receiver\") and fund the channel with a number of tokens. These escrowed tokens will be kept by a third party contract that manages opening and closing of channels.\n\n### Off-chain transactions\n\nHowever, the heart of the system lies in its sender -\u003e receiver off-chain transactions. They offer a secure way to keep track of the last verified channel balance. The channel balance is calculated each time the sender pays for a resource. He is prompted to sign a so-called balance proof, i.e., a message that provably confirms the total amount of transfered tokens. This balance proof is then sent to the receiver's server. If the balance proof checks out after comparing it with the last received balance and verifying the sender's signature, the receiver replaces the old balance value with the new one.\n\n### Closing and settling channels\n\nA visual description of the process can be found [here](http://microraiden.readthedocs.io/en/latest/contract/index.html#closing-a-channel).\n\nWhen a sender wants to close a channel, a final balance proof is prepared and sent to the receiver for a closing signature. In the happy case, the receiver signs and sends the balance proof and his signature to the smart contract managing the channels. The channel is promptly closed and the receiver debt is settled. If there are surplus tokens left, they are returned to the sender.\n\nIn the case of an uncooperative receiver (that refuses to provide his closing signature), a sender can send his balance proof to the contract and trigger a challenge period. The channel is marked as closed, but the receiver can still close and settle the debt if he wants. If the challenge period has passed and the channel has not been closed, the sender can call the contract's settle method to quickly settle the debt and remove the channel from the contract's memory.\n\nWhat happens if the sender attempts to cheat and sends a balance proof with a smaller balance? The receiver server will notice the error and automatically send a request to the channel manager contract during the challenge period to close the channel with his latest stored balance proof.\n\nThere are incentives for having a collaborative channel closing. On-chain transaction gas cost is significantly smaller when the receiver sends a single transaction with the last balance proof and his signature, to settle the debt. Also, gas cost is acceptable when the sender sends the balance proof along with the receiver's closing signature. Worst case scenario is the receiver closing the channel during the challenge period. Therefore, trustworthy sender-receiver relations are stimulated.\n\nTry out the µRaiden demo and build your own customized version, following our instructions below!\n\n\n## Quick Start\n\n * install the Proxy component (more details [here](http://microraiden.readthedocs.io/en/latest/proxy-tutorial.html)):\n\n```bash\nvirtualenv -p python3 env\n. env/bin/activate\npip install microraiden\n```\n\n* install the WebUI component for the paywall examples\n\nNote that while the `RaidenMicroTransferChannels` contract supports multiple open channels between a sender and a receiver, the WebUI component only supports one.\n\n```\ncd microraiden/microraiden/webui/microraiden\nnpm i \u0026\u0026 npm run build\n```\n\n* run the Proxy component:\n\nFor an overview of parameters and default options check https://github.com/raiden-network/microraiden/blob/master/microraiden/click_helpers.py\n\nFor chain and contract settings change: https://github.com/raiden-network/microraiden/blob/master/microraiden/config.py\n\n```\ncd microraiden\npython -m microraiden.examples.demo_proxy --private-key \u003cprivate_key_file\u003e start\n```\n\n * Go to the paywalled resource pages:\n    - http://localhost:5000/teapot\n\n\n# µRaiden\n\n## Installation\n\n### Using `virtualenv`\n\nRun the following commands from the repository root directory.\n\n```bash\nvirtualenv -p python3 env\n. env/bin/activate\npip install -e microraiden\n```\n\n#### Using microraiden in pip's _editable_ mode\nBecause of `gevent` you will need to install microraiden's requirements first.\n```bash\nvirtualenv -p python3 env\n. env/bin/activate\ngit clone git@github.com:raiden-network/microraiden.git\ncd microraiden/microraiden\npip install -r requirements-dev.txt\npip install -e .\n```\n\n### Using a global `pip3` installation\n\n```bash\nsudo pip3 install -e microraiden\n```\n\n## Execution\n\n### HTTP Proxy\nThere are several examples that demonstrate how to serve custom content. To try them, run one of the following commands from the `microraiden` directory:\n```bash\npython3 -m microraiden.examples.demo_proxy --private-key \u003cprivate_key_file\u003e start\n```\nor\n```bash\npython3 -m microraiden.examples.wikipaydia --private-key \u003cprivate_key_file\u003e --private-key-password-file \u003cpassword_file\u003e start\n```\nBy default, the web server listens on `0.0.0.0:5000`. The private key file should be in the JSON format produced by Geth/Parity and must be readable and writable only by the owner to be accepted (`-rw-------`). A ``--private-key-password-file`` option can be specified, containing the password for the private key in the first line of the file. If it's not provided, the password will be prompted interactively.\nAn Ethereum node RPC interface is expected to respond on http://localhost:8545. Alternatively, you can use [Infura infrastructure](https://infura.io/) as a RPC provider.\n### M2M Client\n```bash\npython3 -m microraiden.examples.m2m_client --key-path \u003cpath to private key file\u003e --key-password-path \u003cpassword file\u003e\n```\n\n## Library usage\n\n### Client\nThe µRaiden client backend used by the M2M sample client can be used as a standalone library. After installation, import the following class:\n```python\nfrom microraiden import Client\n\nclient = Client('\u003chex-encoded private key\u003e')\n```\n\nAlternatively you can specify a path to a JSON private key, optionally specifying a file containing the password. If it's not provided, it'll be prompted interactively.\n```python\nclient = Client(key_path='\u003cpath to private key file\u003e', key_password_file='\u003cpath to password file\u003e')\n```\n\nThis client object allows interaction with the blockchain and offline-signing of transactions and Raiden balance proofs.\n\nAn example lifecycle of a `Client` object could look like this:\n\n```python\nfrom microraiden import Client\n\nreceiver = '0xb6b79519c91edbb5a0fc95f190741ad0c4b1bb4d'\nprivkey = '0x55e58f57ec2177ea681ee461c6d2740060fd03109036e7e6b26dcf0d16a28169'\n\n# 'with' statement to cleanly release the client's file lock in the end.\nwith Client(privkey) as client:\n\n    channel = client.get_suitable_channel(receiver, 10)\n    channel.create_transfer(3)\n    channel.create_transfer(4)\n\n    print(\n        'Current balance proof:\\n'\n        'From: {}\\n'\n        'To: {}\\n'\n        'Channel opened at block: #{}\\n'  # used to uniquely identify this channel\n        'Balance: {}\\n'                   # total: 7\n        'Signature: {}\\n'                 # valid signature for a balance of 7 on this channel\n        .format(\n            channel.sender, channel.receiver, channel.block, channel.balance, channel.balance_sig\n        )\n    )\n\n    channel.topup(5)                      # total deposit: 15\n\n    channel.create_transfer(5)            # total balance: 12\n\n    channel.close()\n\n    # Wait for settlement period to end.\n\n    channel.settle()\n\n    # Instead of requesting a close and waiting for the settlement period to end, you can also perform\n    # a cooperative close, provided that you have a receiver-signed balance proof that matches your\n    # current channel balance.\n\n    channel.close_cooperatively(closing_sig)\n```\n\nThe values required for a valid balance proof required by the receiver end are printed above. Make sure to let them know.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraiden-network%2Fmicroraiden","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraiden-network%2Fmicroraiden","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraiden-network%2Fmicroraiden/lists"}