Note

If you are new to the blockchain technology, taking our Introduction to Blockchain Technology self-paced course is highly recommended. Also, for a comprehensive coverage of blockchain development in Ethereum or mastering Solidity programming, taking our below self paced courses is highly recommended:

Recap

In our previous article (Review of scaling solutions for Ethereum), we reviewed different scaling solutions for Ethereum blockchain applications.

In this article, we learn about how to manage Ethereum state channel with Raiden.

State channel with Raiden

Imagine you are taking your family on a cruise ship for a dream vacation. You all will be issued cruise cards at the time you are boarding. Typically the cruise card is linked to your credit card account. It will serve as your ID to get on and off the ship, provide you with access to your cabin, and make it for easy swiping when you decide to have some drinks or buy something.
All onboard purchases are paid for using your cruise card. At the end of the trip when you disembark, you will receive an invoice of all charges charged to your credit card. The cruise card becomes the mutual trust between you and the cruise ship.
The same applies to a digital payment system too. Trusted parties may perform a large number of trivial transactions directly and settle the payment once at some agreed time. That is how Raiden network and state channels work.

State channels are a technique for performing transactions and other state transitions in a second layer built on top of a blockchain. By moving many processes off-chain, the blockchain can be more efficient and scalable, while still retaining transaction integrity and network security.

Payment channels are a type of state channel that allow users to make off-chain payments to each other.
The term state channels generalizes this approach beyond payments. Raiden network is an off-chain network implementation of state channels which enables near real-time, low cost, and highly scalable ERC-20 compatible payments.

Take the examples, as shown in the following diagram: there are about 10 payment transactions between A, B, and C. Many are trivial and insignificant payments. At the end when all three complete the transactions, A will need to pay B for 60 finney (which is one thousandth of an ether), and pay C for 70 finney, and B will need pay C for 110 finney:

Blockchain and Ethereum development

 

With Raiden and State Channels, all three parties would enter an agreement to open the channels, and deposit some coins for payment assurance. All parties can start transactions between parties with their own digital signature; all those micropayment transactions happen in this Raiden network, sometimes called uRaiden. New parties can join or leave the state channel. Any party can check the registered deposits of all parties involved. At the time when any party closes the channel, Raiden network will send a settlement transaction to the main Ethereum blockchain, and the world state will be updated with the new settlement.
As you can see from the following diagram, a settlement transaction with three payments from A to B, A to C, and B to C will be sent to the Ethereum blockchain.

Blockchain and Ethereum development

Both open and close channel transactions happen on the blockchain; they are costly. It is not a good idea always opening new state channels between new parties. For this reason, Raiden allows all participants to form a network of channels, and participants can make off- chain micropayment transactions as long as they are transitively connected to each other.

For example, in the case where A, B, and C, are connected in one state channel, and C and D in another channel, there is no need to create a new direct channel between A and D. The payment can still go through C en route between A and D, although there may be some incentives involved:

Raiden provides Rest APIs for any party to open and close channels, deposit funds, and make payments.

 

Next Article

In our next article (How Plasma Chains Work in Ethereum), we discuss how Plasma Chains work in Ethereum.

This article is written in collaboration with Brian Wu who is a leading author of “Learn Ethereum: Build your own decentralized applications with Ethereum and smart contracts” book. He has written 7 books on blockchain development.

Resources

Free Webinars on Blockchain

Here is the list of our free webinars that are highly recommended:

 

Free Courses

Here is the list of our 10 free self-paced courses that are highly recommended:

 

Self-Paced Blockchain Courses

If you like to learn more about Hyperledger Fabric, Hyperledger Sawtooth, Ethereum or Corda, taking the following self-paced classes is highly recommended:

  1. Intro to Blockchain Technology
  2. Blockchain Management in Hyperledger for System Admins
  3. Hyperledger Fabric for Developers
  4. Intro to Blockchain Cybersecurity
  5. Learn Solidity Programming by Examples
  6. Introduction to Ethereum Blockchain Development
  7. Learn Blockchain Dev with Corda R3
  8. Intro to Hyperledger Sawtooth for System Admins

 

Live Blockchain Courses

If you want to master Hyperledger Fabric, Ethereum or Corda, taking the following live classes is highly recommended:

 

Articles and Tutorials on Blockchain Technology

If you like to learn more about blockchain technology and how it works, reading the following articles is highly recommended:

 

Articles and Tutorials on Ethereum and Solidity

If you like to learn more about blockchain development in Ethereum with Solidity, reading the following articles and tutorials is highly recommended:

 

Articles and Tutorials on Hyperledger Family

If you like to learn more about blockchain development with Hyperledger, reading the following articles and tutorials is highly recommended:

 

Articles and Tutorials on R3 Corda

If you like to learn more about blockchain development on Corda , reading the following articles and tutorials is highly recommended:

 

Articles and Tutorials on Other Blockchain Platforms

If you like to learn more about blockchain development in other platforms, reading the following articles and tutorials is highly recommended: