A previous Reddit post gave some indication:

It's basically Lightning-network style payment channels but for arbitrary state updates. Participants in the Dapp send messages with transactions to each other that update the state but do not publish them to the chain. If one of the participants leaves or tries to cheat the other one can at any time publish the latest transaction to the blockchain to finalize the state. Just the threat of publishing to the chain is enough to keep participants honest.

Are there any architectural diagrams or web3js code examples for implementing State Channels?

up vote 12 down vote accepted

State channels are a generalisation of the idea of payment channels, where two or more users can exchange payments that would normally require a blockchain transaction without needing to use the blockchain or wait for confirmations (except when setting up or closing out the channel). In state channels this idea is extended to apply to any type of application involving interactions among a defined set of users with regard to some sort of state. For example it could be used to play a securely moderated chess game or to grant someone access to temporarily use a blockchain-controlled smart device. A brief description of state channels is linked to in the reddit post you reference.

At present I'm not aware of any code examples which can be used for general state channel implementation. The concept is too new and poorly understood for examples and libraries to be widely available. However, certain projects such as augur and gnosis are using the concept internally within their own applications.

There are some open source demonstrations of state channels. Probably, they act as good inspirations to start implementing something in this direction.

1.https://github.com/AnnaIsAWang/LedgerLabsCoops2016/tree/master/AbstractedStateChannel 2.https://github.com/jtremback/avocado

This newly released repo has a few clear counterfactual examples:

https://github.com/counterfactual/counterfactual/tree/develop/packages

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.