GithubHelp home page GithubHelp logo

vgotemple / jackpot-backend Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 2.0 29 KB

VGO Jackpot Backend on WAX Blockchain

Home Page: https://vgotemple.net/

JavaScript 100.00%
eosjs nodejs mongodb expressjs socketio

jackpot-backend's Introduction

jackpot-backend

VGO Jackpot Backend on Blockchain


Setup

Requirements:

  • NodeJS
  • MongoDB
  • nginx / apache2
  • Wallet on WAX Blockchain (Private Key) (Enough Resources on that Wallet aswell)

Installation: Run following commands

git clone https://github.com/vgotemple/jackpot-backend.git
cd jackpot-backend
npm i

Configure: Now open bin/config.js and edit your details

module.exports = {
    database: {
        url: 'mongodb://localhost:27017/', // Connection to MongoDB Database
        db: 'jackpot-site', // database name
    },
    port: 1337, // Where the socket connection accessible
    blockchain: {
        privateKey: "", // Private Key for your wallet
        accountName: "", // Wallet Account Name (That manages the NFTs)
    },
    jackpot: {
        assoc_id: 1, // ORNG, (Identifier)
        houseEdge: 10, // How much % of the winnings you take as your cut
        countdownTime: 45, // How long it takes to start new round
        minDepositors: 2, // How many unique depositers there have to be to start the game
        spinningTime: 6, // Amount of seconds it waits after winner revealed
        ownerAccountName: "", // Wallet Account Name (The house edge will be sent here)
    },
};

Start: Now start it with:

npm start

Endpoints:

Socket:
Live socket.io connection: http://127.0.0.1:1337/socket.io/

Jackpot:
Current Jackpot Information: http://127.0.0.1:1337/jackpot/
History Pots: http://127.0.0.1:1337/jackpot/history

nginx: Example config:

server {
    listen 80;
    listen [::]:80;

    server_name yourdomain.com www.yourdomain.com; # configure your domain

    root /var/www/yourdomain.com; # Link frontend files

    index index.html;

    location / {
        # Link here to your front end if required:
        try_files $uri $uri/ /index.html =404;
    }

    location /socket.io/ {
        proxy_pass http://localhost:1337/socket.io/; # edit port here
    }

    location /jackpot/ {
        proxy_pass http://localhost:1337/jackpot/; # edit port here
    }
}

With the config:

Live socket.io connection: https://yourdomain.com/socket.io/
Current Jackpot Information: https://yourdomain.com/jackpot/
History Pots: https://yourdomain.com/jackpot/history

Socket Actions:

On Connection: socket.emit("jackpot_game", gameObject)
On client.on("jackpot_game"): socket.emit("jackpot_game", gameObject)
On client.on("ping", input): socket.emit("pong", input)

Jackpot Interval:
On Countdown: socket.emit("jackpot_countdown", gameObject.countdown)
On Update: socket.emit("jackpot_status", gameObject.status)
On Status Update: socket.emit("jackpot_status", gameObject.status)
On Deposit: socket.emit("jackpot_deposit", depositObject)
On Roll (When Spinner starts): socket.emit("jackpot_winner", gameObject.winner)
On New Game: socket.emit("jackpot_game", gameObject)


Objects:

Jackpot Game:

{
   "id": 1, // GameID
   "countdown": 60, // CountDown in seconds
   "deposits": [ {/** Deposit Object */} ], // all deposits in this pot
   "lastDBUpdate": 1278583978990, // last time database updated this pot
   "status": 0, // game status (see: GameStatus Object)
   "worth": 1230, // pot worth in cents
   "outcome":
   {
        "trx_id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", // transaction id for orng outcome generation
        "data": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", // orng outcome
        "percent": 0.420691337 // calculated outcome from orng outcome
   },
   "winner": "winner.wam", // winner of pot
   "winningTicket": 99 // ticket that won
}

Deposit:

{
    "accountName": "depositor.wam", // account that deposited the nft
    "nfts":
    [
        {
            "id": "100000000378323", // assetid
            "author": "vgo", // author of nft
            "category": "............1", // nft category by simpleassets
            "idata": {}, // Immutable asset data
            "mdata":
            {
                "name": "Dual Berettas | Trigger Happy (Battle-Scarred)", // VGO Skin Name
                "img": "QmWz9qM6z5NL1F11rtMdQcYj2Cxdqsyye5BZbwREWf8Nm5", // VGO Skin Image (Link: https://ipfs.io/ipfs/QmWz9qM6z5NL1F11rtMdQcYj2Cxdqsyye5BZbwREWf8Nm5)
                "unique": "QmPaYpbudFJhnUcRSSWqouoFKEXuknb2X9HJR41wUfWAMc", // Unique Data (Link: https://ipfs.io/ipfs/QmPaYpbudFJhnUcRSSWqouoFKEXuknb2X9HJR41wUfWAMc)
                "generic": "QmRdFvXcgWisohhRFa4LFTHTpMEj6ftd3jAskedBjz5yUt" // Generic Skin Data (Link: https://ipfs.io/ipfs/QmRdFvXcgWisohhRFa4LFTHTpMEj6ftd3jAskedBjz5yUt)
            },
            "rarity": "Mil-Spec", // rarity of vgo skin
            "worth": 3 // VGO Skin worth in cents
        }
    ],
    "worth": 3, // total deposit worth in cents
    "trx_id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // Deposit transaction id
}

GameStatus:

{
    "WAITING_FOR_DEPOSITS": 0,
    "COUNTDOWN": 1,
    "WAITING_FOR_OUTCOME": 2,
    "ROLLING": 3,
    "ROLLED": 4,
}

jackpot-backend's People

Contributors

vgotemple avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

todokku colinaa

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.