Git Product home page Git Product logo

rock-paper-scissors's Introduction

Rock Paper Scissors

Tests Badge Slither Badge

The game starts by the 1st player sharing a commit hash and sending the required fee. From this point on, a 2nd player can join the the same game using the unique gameId associated to this game. The 2nd player would need to send their move (rock, paper or scissor) along with the required fee to play the game. After a 2nd player joins the game, the 1st player would need to reveal their move by sharing their move along with the nonce they used to created their commitment hash which was shared earlier during the game creation. Finally, anyone (either the players or a 3rd party) can call the finalize function on the contract using the same gameId to end the game if all the required criteria are met and distribute the prizes among the winners.

This repository uses foundry/forge to compile and test the contracts.

To install dependencies run:

forge install

To test run:

forge test

Vulnerabilities

If a game ends in a tie, a malicous actor can play a game against themselves to win the accured poolAmount. Even if we add a check to make sure the two players have different addresses, the bad actor can easily use 2 different wallets.

For additional vulnerability analysis, we also use Slither:

slither src/RockPaperScissors.sol

Slither returns vulnerabilities against the internal _sendETH function which is guarded against reenterency using a locking mechanism at 2 different locations.

TODO

  • Clean up the test file
  • Optimize the main contract

rock-paper-scissors's People

Contributors

saw-mon-and-natalie avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.