hi so my name's tom close i am the
founder of magma and we are a state
channel research and development company
and today as the title suggests i am
going to be talking about building a
state channel application so in fact an
alternative title of this talk could
actually be this we built a state up
channel application and we found it
really hard it turns out that this is a
pretty accurate description of the
situation so this talk is going to be
partly show and tell it's going to be
partly like group therapy and partly a
call for help so before I go into that
let me tell you a little bit more about
who we are because maybe some of this a
little bit relevant to why we found it
hard but maybe some of it isn't and I'll
talk about that later too so we are a
team of six researchers and developers
so we're all pretty experienced I guess
we've got like three or four people
who've got like more than five five
years experience developing or
insecurity half our team have PhDs but
we're all new to the blockchain
so it's this time last year that I
started working the blockchain everyone
else is more recent the blockchain than
I am and more recent to aetherium
obviously so let me now talk a little
bit this show-n-tell part so today we
have launched this application where you
can play rock-paper-scissors in state
channel I can see by the like dumbstruck
silence that everyone is like utterly
amazed by that and to be honest
rock-paper-scissors is not the most
exciting game let me just quickly take
you through it how it works I'm not
going to do a live demo but I do have a
little video so here somebody is logging
into the app they're putting in their
name and they're gonna
eight a challenge for someone else to
join so they're gonna say we're gonna
play rock-paper-scissors and we're gonna
play for this match each round they put
that challenge up on the next left side
we've got player to George he's about to
login I mean he's gonna accept the first
player's challenge first player confirms
and then we get into this state where
your channel wallet comes out and your
channel wallet is something that any
state channel application will need if
you're exchanging States with someone
those states are as almost as important
as as real money so like if you lose
your state's you can use everything so
you need this wallet thing any state
channel network will need some sort of
channel wallet to manage the states that
are being sent across so here you can
see they are depositing into an
Unchained contract
so they're both locking some funds up on
chain and those are the funds that we're
going to play for in this game so in a
moment both those transactions would
have gone through and they can return to
the game so you can see we've got this
state of the game here they've each got
five five each as it were and now
they're going to play
rock-paper-scissors so behind the scenes
here this app is implementing a state
channel protocol so it is signing States
and exchanging those states between the
users and I'll talk a little bit more
about that how we're actually thinking
about those applications so this is
built on top of a framework called force
move I'll talk a little bit more about
how this actually works with force move
later we're just going to go through to
the end of the game I think George is on
a winning streak it's not going to take
much longer hopefully yeah he's getting
there so yeah at the end of the game one
of the things about this sort of state
general application is we're playing one
game of rock-paper-scissors we needed
one on chain deposit the beginning and
what we'll see in a minute is another on
chain deposit at the end this is
something that when we have like virtual
channels in state channel networks
you'll be able to get away with
one deposit at the beginning of the
month and then you'll be able to play
multiple games like this opening these
channels and closing them off chain so
that's like an important area of future
research which we'll probably be looking
at in the future anyway so this is the
demo this is the example app that we've
put together so you're excited at the
beginning you're probably even more
overwhelmed now you've seen it in action
I'm seeing a lot of stunned faces
clearly a winner so what was hard about
this so I guess part of the problems
where the standard blockchain problems
that everyone experiences when they're
new to the blockchain and when they're
trying to develop on the blockchain and
I'm not gonna really talk about that
aspect of things so much because that's
common to like all the projects so the
problems about setting up your app to
work with typescript and integrate with
truffle or like whichever other
developer framework you're using I'm not
going to really touch on that I'm not
going to really touch on like the
problems with meta masks when you're
developing and having to flick the
network back and forwards and taking a
while to realize that stuff and like I'm
not going to definitely are going to
talk about the eight weeks we spent
debugging solidity by omitting events
before we realized there was a solidity
debugger so a lot of that is just like
part and parcel of developing on
aetherium we're interested in learning
from other people in the room how to
better do that we've learnt a lot of
this stuff by trial and error but like
they're probably still a load of stuff
we don't know so one of the things I
wanted to spend the last few minutes of
this talk talking about is what are the
essential things the things essential to
state channels that we found difficult
and I guess the way I would look at this
I'm going to focus on this one problem a
hard thing about state channels is state
and managing state so what
mean by that so we were working we're
building this app on top of the force
move framework and the force move
framework has a very simple way of
managing state and thinking about the
state of your state channel and your
state transitions so this is a
representation of rock-paper-scissors in
the force move framework you have four
different states if you're trying to
program this as a developer building on
top of the framework you're responsible
for writing a single library contract
with a valid transition function which
defines these states and the valid
transitions between them so in the face
of that that seems pretty simple and
it's pretty conceptually simple to think
about what's happening actually in the
state channel and what's happening on
the chain and that's one of the nice
things about what we are working with
it's like one of the simpler state
channels frameworks to work with but in
terms of your app there are like many
many more states so we actually came to
like interacting with those four states
force four types of messages that we're
sending back and forth we ended up with
this diagram and this doesn't even
include the wallet stuff that we showed
all of those wallet states have been
collapsed into like dates to the top so
I guess why is this this complicated and
I guess if you think about it like back
in the very early days of the web you
had like a user who was interacting with
a server and that was like pretty simple
like the state was the state that was
stored on the server there's one way of
interacting with it you put it back on
the server there's one source of truth
now in recent years things have got a
bit more complicated so you now have
front-end JavaScript apps so you've got
like the state your local state and then
you've got the updated state on the
server and you're interacting with your
local state and maybe somebody else is
interacting with the server and you like
can receive updates and then the
blockchain adds an extra dimension into
that so the blockchain is like another
player and that maybe you've replaced
your server with the blockchain maybe
you've got a server and you've got a
blockchain we've now got multiple places
these updates can come from and state
channels add yet another place where
those
dates can come from and in a state
channel your whole logic is around I'm
receiving these states from my
counterparty and therefore I can like
reason about what's happening on chain
and that just gets very complicated to
think about and stuff so like we're now
thinking about this thinking about how
we can make it simpler thinking about
how we can take this thing which seems
in some way inherently complex and work
with it better think you have better
ways to manage this complexity in the
applications so final plug so this the
code you saw today the demonstration
it is currently live on Rob stone so you
can visit it at magno calm slash RPS in
case you don't find any friends there we
have some bots that you can play against
they get progressively harder
the final bot is the psychic bot and if
you can beat the psychic bot we want to
hear from you you'll get like I'll give
you a Twitter shout-out prizes prizes
are limited but you'll get like small
fleeting honor in terms of a magnet
Twitter shout-out I think I'm out of
time though thanks for listening
you can follow us at magma HQ on Twitter
you