Raiden Network
  • What is Raiden?
  • Installation
    • Quick Start
      • Get MetaMask
      • Get an Infura ID
      • Download and run the Raiden Wizard
      • Handle Limitations
    • Starting Raiden Manually
  • Using Raiden on Mainnet
    • Overview
    • Get Whitelisted Tokens
    • Deposit Tokens to the UDC
    • Open a Channel
    • Make a Payment
    • Deposit Tokens
    • View Channel Status
    • Mediation Fees
  • The Raiden Web Interface
    • Overview
    • Navigate the WebUI
    • Join a Token Network
    • Make a Payment
    • Add More Tokens
    • Settle Payments and Close Channels
  • Using Raiden on testnet
    • Quick Start on Görli Testnet
    • Use Custom Token
      • Get Goerli Testnet ETH (GÖETH)
      • Import Custom Token
      • Compile Imported Token Code
      • Deploy Custom Token
  • Raiden API
    • Introduction
    • Resources
      • Address
      • Version
      • Settings
      • Contracts Information
      • Tokens
      • Channels
      • Payments
      • Connections
      • Pending Transfers
      • Shutdown
      • Testing
    • API Tutorial
      • Create a Token Network
      • Open a Channel
      • Deposit Tokens
      • Make a Payment
      • Withdraw Tokens
      • Settle Payments and Close Channels
  • Other
    • Safe Usage
    • Known Issues
    • Glossary
    • v1.0 Documentation
    • Trademark Attributions
Powered by GitBook
On this page
  • Close a specific channel
  • Leave a token network and close all channels

Was this helpful?

  1. Raiden API
  2. API Tutorial

Settle Payments and Close Channels

Closing a channel will settle the balance between you and your peer. This means that both of you will receive your net balance of tokens back on-chain and the balance of the channel will be 0.

PreviousWithdraw TokensNextSafe Usage

Last updated 4 years ago

Was this helpful?

You can choose to either:

Close a specific channel

Closing a specific channel is done with a PATCH request to the endpoint that includes:

  1. The token address as a path parameter.

  2. The address of the partner node as a path parameter.

  3. The state set to "closed" in the body parameter.

curl -i -X PATCH \
http://localhost:5001/api/v1/channels/0x9aBa529db3FF2D8409A1da4C9eB148879b046700/0x61C808D82A3Ac53231750daDc13c777b59310bD9 \
-H 'Content-Type: application/json' \
--data-raw '{"state": "closed"}'

A successful response will return a normal channel object with the state set to "closed".

HTTP/1.1 200 OK
Content-Type: application/json

{
    "token_network_address": "0x3C158a20b47d9613DDb9409099Be186fC272421a",
    "channel_identifier": "99",
    "partner_address": "0x61C808D82A3Ac53231750daDc13c777b59310bD9",
    "token_address": "0x9aBa529db3FF2D8409A1da4C9eB148879b046700",
    "balance": "350",
    "total_deposit": "7331",
    "total_withdraw": "0",
    "state": "closed",
    "settle_timeout": "500",
    "reveal_timeout": "50"
}

The settle timeout period will start as soon as a channel is closed and the channel is settled once the settle timeout period is over. The state of the channel will then be changed tosettled.

Leave a token network and close all channels

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

Once done, the response will return a list containing the addresses of all closed channels.

HTTP/1.1 200 OK
Content-Type: application/json

[
    "0x41BCBC2fD72a731bcc136Cf6F7442e9C19e9f313",
    "0x5A5f458F6c1a034930E45dC9a64B99d7def06D7E",
    "0x8942c06FaA74cEBFf7d55B79F9989AdfC85C6b85"
]

Please note that leaving a token network will take some time since you need to wait for the settle timeout to expire for each channel before a settle can happen.

If you wish to leave a token network altogether you can do so by making a DELETE request to the endpoint with the token address as a path parameter.

Close a specific channel
Leave a token network and close all channels
connections
channels