 H Double please. I am The Founder of Magmo and we are a state channel research and development company. Today, as the title suggests, I am going to be talking about building a state channel application. In fact, an alternative title of this talk could actually be this. We built a state 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. Cos maybe some of this is a little bit relevant to how we found it hard, 감사합니다. Mae'n ddylai cael hyffanc i mi neu rôl, ac mae'n ddigonol o bobl ar burio. Mae'n ddigonol o bobl arall. Mae'n ddigonol o bobl ar burio, a byddwn i chi i mi. Mae gennych, maen nhw, mewn ddigonol o bobl. Mae gennych, faint, ond mae'n ddigonol o'r bobl ar angen a bobl hawdd. Mae'n llaw ar mwynhau roedd, ofer mwynhau a'r angen, mae'r ddylo datgan. Mae gennych, mae'n ddigonol a byddwn nifer. Mae'n i mwynhau ar y blok chain. Mae'n dyma'r angen, I started working in the blockchain, everyone else is more recent to the blockchain than I am, and more recent to Ethereum, obviously. So, let me now talk a little bit, this is the show and tell part. So, today we have launched this application where you can play rock, paper, scissors in a state channel. I can see by the dumbstruck silence that everyone is utterly amazed by that. 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 going to create a challenge for someone else to join. They're going to say, we're going to play rock, paper, scissors, and we're going to play for this much each round. They put that challenge up. On the left side we've got player two, George, who's about to log in, and he's going to accept the first player's challenge, first player confirms, and then we get into the 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 almost as important as real money. If you lose your states you can lose 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. Here you can see they are depositing into an on-chain 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. In a moment both those transactions will have gone through and they can return to the game. You can see we've got this state of the game here. They've each got five each, as it were, and now they're going to play rock, paper, scissors. Behind the scenes here, this app is implementing a state channel protocol. It is signing states and exchanging those states between the users. I'll talk a little bit more about that, how we're actually thinking about those applications. This is built on top of a framework called ForceMove. I'll talk a little bit more about how this actually works with ForceMove 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. He's getting there. At the end of the game, one of the things about this state channel application is we're playing one game of rock, paper, scissors. We needed one on-chain deposit at the beginning. What we'll see in a minute is another on-chain deposit at the end. This is something that when we have virtual channels in state channel networks, you'll be able to get away with one deposit at the beginning of the month. Then you'll be able to play multiple games like this, opening these channels and closing them off-chain. That's an important area of future research, which we'll probably be looking at as a point in the future. This is the demo. This is the example app that we've put together. 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. What was hard about this? Part of the problems were the standard blockchain problems that everyone experiences when they're new to the blockchain and when they're trying to develop on the blockchain. I'm not going to really talk about that aspect of things so much because that's common to all the projects. The problems about setting up your app to work with TypeScript and integrate with Truffle or whichever other developer framework you're using, I'm not going to really touch on that. I'm not going to really touch on the problems with Metamask when you're developing and having to flick the network back and forwards and taking a while to realise that stuff. I'm definitely not going to talk about the eight weeks we spent debugging Solidity by emitting events before we realised there was a Solidity debugger. A lot of that is part and parcel of developing on Ethereum. 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 there are probably still loads of stuff we don't know. 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? 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. What do I mean by that? We're building this app on top of the force move framework. 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. This is a representation of rock, paper, scissors in the force move framework. You have four different states. If you're trying to programme 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. On the face of that, that seems pretty simple. It's pretty conceptually simple to think about what's happening in the state channel and what's happening on the chain. That's one of the nice things about what we're working with. It's one of the simpler state channels frameworks to work with. In terms of your app, there are many, many more states. When we came to interacting with those four states, four types of messages that we're sending back and forth, we ended up with this diagram. This doesn't even include the wallet stuff that we showed. All of those wallet states have been collapsed into states at the top. Why is this this complicated? If you think about it, back in the very early days of the web, you had a user who was interacting with a server. That was pretty simple. 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. In recent years, things have got a bit more complicated. You now have front-end JavaScript apps. You've got the state, your local state, and then you've got the updated state on the server. You're interacting with your local state and maybe somebody else is interacting with the server and you can receive updates. The blockchain adds an extra dimension into that. The blockchain is like another player in that. Maybe you've replaced your server with the blockchain, maybe you've got a server and you've got a blockchain. You've now got multiple places that these updates can come from. State channels adds yet another place where those updates can come from. In a state channel, your whole logic is around I'm receiving these states from my counterparty and therefore I can reason about what's happening on chain. That just gets very complicated to think about and stuff. 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. I think you have better ways to manage this complexity in the applications. Final plug, the code you saw today, the demonstration, it is currently live on Robston. You can visit it at magmo.com.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. If you can beat the psychic bot, we want to hear from you. You'll give you a Twitter shout-out. Prizes are limited, but you'll get small fleeting honour in terms of a magmo Twitter shout-out. I think I'm out of time. Thanks for listening. You can follow us at magmo.hq on Twitter.