Back Understanding Ethereum
district0x
General

The Basics of State Channels

What Are State Channels?

State channels refer to the process in which users transact with one another directly outside of the blockchain, or ‘off-chain,’ and greatly minimize their use of ‘on-chain’ operations. It’s one of the most exciting Ethereum scaling solutions in development and the closest advancement to being production ready.

State channels are very similar to the concept of payment channels in Bitcoin’s Lightning Network, but instead of only supporting payments, they also support general ‘state updates.’ For example, votes conducted on the District Registry could be updated in a state channel and only broadcasted to the Ethereum network once all votes have been collected. This magnifies the number of computation developers can move off-chain.

 

Why Is This Exciting?

While at first glance it might seem like transactions within state channels aren’t backed up by the same level of security as on-chain transactions, the magic is that we can achieve the same level of security without using as much of the network’s resources. By being able to always revert back to the main chain as an arbitration mechanism, users are game-theoretically incentivized to act rationally. Also, each transaction is signed the same way a valid Ethereum transaction would be.

On-chain transactions aren’t completely eliminated but rather reduced to only the necessary sequences. Users have to create and pay for an Ethereum transaction when they first open up the channel. When they’re ready to close the channel, they again have to pay fees to process a transaction on the Ethereum blockchain. Cutting the number of necessary on-chain transactions down to two drastically reduces the costs and increase the speed associated with using Ethereum.

Think of State Channels like a time card you’d use at work. You punch in when you begin working (Transaction #1) and you punch out at the end of the shift (Transaction #2). Every action that happens in the middle doesn’t need to be logged on the time card.

 

State Channels Under the Hood

State Channels sound great in theory, but they’re even more interesting when looking at them in practice. Here’s a brief example to illustrate how they functionally work:

  1. Users lock up a portion of the state by sending money to a multisignature contract that has the ability to accept Ether and payout all parties who have sent it Ether.
  2. Users sign transactions and send them to one another, each one making a copy of the signature for later reference.
  3. Each transaction contains a nonce so the smart contract can know the chronological order of transactions.
  4. Once both parties are done, they close the state by submitting a transaction to the Ethereum blockchain.
  5. After the state is updated and unlocked, the smart contract sends each party their remaining Ether balance.

 

Why It’s Important

Scaling is arguably the biggest obstacle that blockchains face when it comes to achieving mainstream adoption. While some applications can thrive today, most are still too slow and expensive for regular users.

State channels increase the throughput of public blockchains because they decrease the computational load that nodes have to expend when processing and storing transactions. This will make it easier to run a node, which makes the job of validating the miners’ work more decentralized. Similarly, State Channels reduce the costs required to use the Ethereum network. Instead of paying fees for each transaction, users only have to pay for gas when they open and close a channel.

State channels also help preserve user privacy. Transactions within a channel are only known by the participants in the channel. This is in contrast to transacting on the Ethereum blockchain where every transaction is recorded in a publicly auditable ledger.

Lastly, transactions within state channels get instant finality. Users don’t have to wait for each transaction to confirm onto the blockchain because each signed transaction abides by the network rules. This makes the user experience seamless and more mirrors how popular online applications operate today.

Was our Education Portal helpful?

Share

Dont Miss Out On Updates!

Subscribe to our newsletter to stay up to date on all the happenings in the district0x network.