-
Notifications
You must be signed in to change notification settings - Fork 10
Recipe: Initialising a simple state channel
Liam Horne edited this page Jul 20, 2017
·
5 revisions
Warning: still under construction
How to safely initialise a simple fully abstracted state channel with a single payment sub-channel contained inside of it (ignores some incentive compatibility requirements that would aid performance).
An adjudicator factory, a nonce comparer, a bulletin board to handle counterfactual addressing, a call library to handle insertion of addresses into counterfactual calls, and a set of participants A,B,.. who will participate in the channel.
- Create proxy contracts for A,B,...
- Create the Unanimous Consent contract, passing in the proxies from step 1 as the participants.
- Counterfactually instantiate the lock adjudicator (from here on all calls/instantiations should require the lock adjudicator to still have empty state/nonce of "0").
- Counterfactually instantiate the payment channel adjudicator.
- Counterfactually call the payment channel adjudicator and update its state to [nonce, A's initial intended deposit, 0, ...]
- Counterfactually make a lookup of the payment channel adjudicator's state, ensure that it's frozen, read the array, and pay out each respective value's worth in the array to A,B,...
- A can now safely deposit their initial amount on-chain.
- Repeat steps 5 and 7 for B,... with the successive slots in the payment channel adjudicator state array.
- The payment subchannel is now configured! To send money between participants, sign commitments to calls that increment the payment channel adjudicator nonce and adjust the array values to reflect the intended transfer.