fbpx

Rock paper scissors Solidity tutorial

Julien Klepatch

You know Rock paper scissors right? If you don’t, that’s a simple game where in each round 2 players make one of 3 moves:

  • rock
  • paper
  • scissors

Paper beats rock, scissors beat paper, and rock beats scissors. You can also bet money in each round, to make it more interesting.

I will show you how to do this game in a Solidity smart contract with this video tutorial.

It might seems like it’s easy to do, but there is a caveat: on the blockchain, all data is public, there is no private data. So, if the first player sends his move in clear the smart contract, the second player can read this data, even if you mark the variable as private in Solidity. Since the second player can always anticipate the move of the first player, he will always win! Not an ideal situation… how can we prevent this? With a “commit – reveal” scheme. This pattern is not just applicable to this game, but also to all situations where you need to deal with private data on the blockchain. Watch this video and I will show you how it works!

0 Comments

Leave a Reply

More great articles

Contract Inheritance In Solidity | Episode 6

https://youtu.be/BIHNMvbqr0k In object-orientated programming languages, we have classes and inheritance. In Solidity, we don't have classes but we have contracts.…

Read Story

DAO – Part II

In this video, we start to build the DAO smart contract, and implement the following features: Collect investor money in…

Read Story

ToDo List Ethereum Dapp (Step1) | Writing The Smart Contract – Part I

This tutorial is part of the series ToDo List Ethereum Dapp. It is the Step 1. Tutorials already published: Intro…

Read Story

Never miss a minute

Get great content to your inbox every week. No spam.
[contact-form-7 id="6" title="Footer CTA Subscribe Form"]
Arrow-up