Is there a virtual channel tutorial?

The protocol tutorial has ledger channels (site, repo), but that just shows you how to create multiple channels with the same parties using the same deposit. I would really like to allow anyone with deposits to theahub to be able to make a channel together off chain, as described in the nitro whitepaper.

It feels quite complex though, and some reference code would save me a lot of time. Thanks!

We don’t yet have a tutorial for that. I started putting one together, but it is only a work in progress at this point: Off-chain funding | statechannels docs

If you had any time to contribute to finishing this section of the tutorial, that would speed things up and might be a great way to understand the off-chain virtual funding protocol. Let me know if you are interested!

The other reference code you could look at is inside our browser wallet:

1 Like

Yeah I’m definitely interested! I’ll see what I can add to your PR as I explore this area.

If the code for virtual funding as a leaf or hub is already implemented in the browser-wallet, does that mean there is a nice way to get virtual funding working in the browser without worrying about the internals? Say, is there a method I missed in @statechannels/channel-client? If so, can I get the hub working on a node server with the code, or is it specifically for the browser?

Virtual funding as a leaf and as a hub are both implemented in the browser wallet! They are also used in web3torrent, whose source can be found here. I believe web3torrent still works, but I don’t have any Goerli eth handy to test it out.

Behind the scenes, there’s a “simple hub” that optimistically signs state updates, which enables the virtual funding flow. Thus, the hub is trusting the “leaves” not to operate out of protocol, meaning it would easily give away some (Goerli) eth if you sent it some manually crafted state updates!

Note that web3torrent & the simple hub are using some older versions of some packages.

We have a working nodejs server wallet, but unfortunately it is not yet interoperable with the browser wallet. We are currently finalizing some research, before implementing an optimized protocol!

1 Like

I tried web3torrent out the other day and I downloaded the sample file no problem, so I assume it’s working!

Awesome thank you this is exactly the kind of thing I was looking for! Are there plans to make the simple hub less naive so it can be used in production? Or is it just supposed to be a placeholder for the server wallet?