Deploying the contract and playing rock paper scissor on blockchain.

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To 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.

This video is available to students only
Unlock This Course

Get unlimited access to newline's Introduction to Privacy on Ethereum, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course newline's Introduction to Privacy on Ethereum

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. 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. 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. It's not perfect. We know that you can write it much better. You can do a lot of fancy stuff. You can probably even do it in a single line. 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. So now we can we can go and of course deploy this contract. So we can compile it. 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. 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. 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. 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. 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. So this is the c4 and c4 made a choice which was which was one. So rock made scissors, which is what we expect. 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.