Deploying the contract and playing rock paper scissor on blockchain.
Get the project source code below, and follow along with the lesson material.
Download Project Source CodeTo set up the project on your local machine, please follow the directions provided in the README.md
file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.
This lesson preview is part of the newline's Introduction to Privacy on Ethereum course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.
Get unlimited access to newline's Introduction to Privacy on Ethereum, plus 70+ \newline books, guides and courses with the \newline Pro subscription.
[00:00 - 00:17] So let's go through this a bit more. So we have if Alice played rock and what played paper then Bob won if foreplay, rock and Alice played paper then Alice won if Alice played scissors and what played paper then Alice won.
[00:18 - 00:43] And if both played scissors and Alice played paper then Bob won if Alice played rock and what played scissors and Alice won and if Bob played rock and Alice played scissors then Bob won. So these are just the rules of the game.
[00:44 - 00:54] It's the same with like if you're implementing tic-tac-toe or if you're implementing any of those. And this is essentially a basic version of the game we have.
[00:55 - 00:58] It's not perfect. We know that you can write it much better.
[00:59 - 01:04] You can do a lot of fancy stuff. You can probably even do it in a single line.
[01:05 - 01:16] But just to keep it simple, we have it this way. And so now I want you to think about what are the most common problems with this approach.
[01:17 - 01:23] So now we can we can go and of course deploy this contract. So we can compile it.
[01:24 - 01:35] It's already an auto-compile and of course we can deploy it. So when you deploy the game, you can you can do different things and you can of course check that indeed it will work.
[01:36 - 01:56] So you can play. So this guy with the address ending at c4 is playing a move that is let's say rock and you can play the move and it successfully registers it and now I'm going to use the second address.
[01:57 - 02:10] So now you can see it's p2 instead of c4 and that's going to play let's say scissors. So it's rock versus scissors, which means that scissors should win.
[02:11 - 02:34] Now of course we can check the choices here with the address and what we're going to say is let's see who wins. So we're going to copy the address from here and the address I'm just going to paste it with a comma and I'm going to copy the second address and again paste it after that.
[02:35 - 02:49] I'm so finished and let's see you evaluate. So it says that the address with c4 has one and let's look at the choice of c4.
[02:50 - 03:05] So this is the c4 and c4 made a choice which was which was one. So rock made scissors, which is what we expect.
[03:06 - 03:25] So the game is working on to a very basic level and I want you to write down all the problems that you think of this play around with it if you have anyone give them an address and play around with them and see what it is and we'll talk about all the problems with this approach in the next lesson.