Giter VIP home page Giter VIP logo

tomogamefrontend's Introduction

Welcome to Blockchain Confetti 👋

Description

This is the game that answers the question. There are a total of 10 questions, each player will have to bet 3 Tomo for a question. If true, they will receive some Tomo equal to the total number of tomo of all participants answered divided by the number of correct respondents. If the answer is wrong, the player will not get anything back. The players answer all questions correctly will receive a reward from Admin. If no one answers correctly in a question, the bet amount will be transferred to Admin and the game will end.

Feature

  • Build on ReactJS, Firebase .
  • Blockchain tech with Tomochain.

For end user: Play the game

The game participants will have 2 roles

  • Admin
  • Player

For Admin

If you are Admin go to /admin

playGame

If you are the Admin you need to create game first and then select the question. After 10s Admin can publish the answer of the question and divide Tomo for the players who have answered correctly by pressing the Question Sharing button. After everyone answers 10 questions , press Bounty Sharing button to divide the money for players who have correctly answered 10 questions .

For Player

Open the app, click Play Game Button

playGame

After send Tomo to Game Account . Players will wait for Admin to create a new game

waitingNewGame

After the Admin created the game and choose the first question the game will start. Player will have 10 seconds to answer the question. Players can see what other player choose and give own answers.

answerQuestion

The game has a scoreboard and a ranking to see who answers the most questions correctly.

scoreAndRanking

The player who answered correctly all 10 questions will be the final winner.

winner

In the process of playing, you can withdraw the initial deposit and the interest amount when give correct answer at any time.

For developer

General

There are serveral main components in this project:

  • Contracts
    • Solidity
    • Tomochain testnet
  • Frontend
    • ReactJs
    • Redux
    • Web3.js
  • Database
    • Firebase

(we will update latest source code later)

How to install

Set up Firebase

We are using firebase for database , you need to create a project in firebase after that click Add Firebase to you web app and copy script firebaseConfig to src/config/index.example.js

var firebase = require('firebase/app');
require('firebase/firestore');
require('firebase/auth');

var config = {
  apiKey: '<YOUR_API_KEY>',
  authDomain: 'YOUR_AUTH_DOMAIN',
  databaseURL: 'YOUR_DATABASE_URL',
  projectId: 'YOUR_PROJECTID',
  storageBucket: 'YOUR_STORAGEBUCKET',
  messagingSenderId: 'YOUR_MESSAGING_SENDER_ID'
};

firebase.initializeApp(config);

module.exports = firebase;

After that run script to setup firebase:

npm run firebase

or

yarn firebase

Set up Contract

npm install

or

yarn install

Then, adding a new .env file :

MNENOMIC = 'YOUR PRIVATE SEED PHRASE';

Migrate contract:

In this application, we are using Tomochain testnet to migrate smart contract and truffle framework to deploy.

You can migrate your contracts by command:

yarn truffle migrate --network tomotestnet

Some files will appear in build/contracts folder, there are contracts code after migrated. You need to move folder contracts to /src in frontend folder.

Set up Frontend

npm install

or

yarn install

then

npm start

or

yarn start

Known issues

Due of short duration of development in this hackathon, we've faced many trouble, and some even still exitst in latest build.

  • Displays the number of players who choose the answer sometimes wrong.
  • 10 seconds for players to answer questions confirmed on the blockchain by counting next 5 block confirmation, sometimes users have less than 10 seconds to answer the question.
  • Other minor bugs...

Next Plan

In future in next versions, we are going to fix all bugs and publish the game in other platforms version, too. And of course, support multichain like Tomochain mainnet, ETH mainnet, Ropsten, Loom, Rinkeby....

Show your support

Give a ⭐️ if this project helped you!

tomogamefrontend's People

Watchers

 avatar

tomogamefrontend's Issues

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.