Giter Site home page Giter Site logo

cryptojenga's Introduction

CryptoJenga

This is a multiplayer betting game by allowing users to participate in round-by-round play where each round has specified duration (when game is created).

The front-end is built using Unity game engine and there is a backend monitoring the events emitted by the smart contract.

Chainlink features used

  • Price feed: the ticket price is in USD. The price feed is used for the conversion.
  • VRF: used for choosing the winning answer and the winner
  • Keeper: automatically move from round to round and end the game based on the duration defined.
sequenceDiagram
    participant FrontEnd
    participant SmartContract
    participant ChainLink_PriceFeed
    participant ChainLink_VRF
    participant ChainLink_Keeper

    FrontEnd->>+SmartContract: Start a game
    SmartContract->>SmartContract: constructor 

    Note right of SmartContract: address _priceFeedAddress <br/>address _vrfCoordinator <br>uint256 _linkFee<br>bytes32 _keyhash (VRF)<br>uint256 _ticketPrice<br>uint _roundDuration
   Note left of ChainLink_PriceFeed:   struct Bet {<br>uint256 betAmount<br>Signature betSignature<br>string betString<br>}
 
    SmartContract -->> -FrontEnd: Contract Deployed

    SmartContract -->> FrontEnd: Emit Round 1 started event

    FrontEnd ->> +SmartContract: place a bet
    Note right of SmartContract: uint Amout <br/>uint8 v<br>bytes32 r<br>bytes32 s;
    ChainLink_PriceFeed -->>SmartContract: USD to ETH conversion rate
    SmartContract ->>-SmartContract: determine if the bet can be taken
    Note right of SmartContract:mapping(uint256 => mapping(uint256 => mapping ( address => bool))) placedBet<br> mapping(uint256 => mapping(uint256 => mapping ( address => Bet))) bets

    ChainLink_Keeper-->>+SmartContract: RoundEnded
    SmartContract-->>FrontEnd: emit round end event
    SmartContract->>ChainLink_VRF: request random number
    ChainLink_VRF-->>SmartContract: request random number
    SmartContract ->>-SmartContract: determine the winning number

    FrontEnd ->> +SmartContract: reveal the bet
    Note right of SmartContract: string betString
    SmartContract ->>-SmartContract: save the betString if pass verification

    ChainLink_Keeper-->>+SmartContract: Reveal peroid end
    SmartContract->>-SmartContract: calculate the winner for the round
Loading

cryptojenga's People

Contributors

bill-lu avatar build509 avatar st4rgut24 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.