This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" dir="ltr"> | |
<head> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="game.css"> | |
<title>Dice ethereum game</title> | |
</head> | |
<body> | |
<div class="main-container-game"> | |
<h1>Ethereum Dice</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
font-family: sans-serif; | |
} | |
.hidden { | |
display: none; | |
} | |
.main-container-game { | |
margin: auto; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let activeDice = 0 | |
let game = {} | |
let isThisPlayer1 = false | |
let isThisPlayer2 = false | |
let sequence = 1 | |
start() | |
// In the start we get the initial data needed to get the contract address | |
async function start() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// On finish send the 2 latest messages which are contained in the last element. | |
socket.on('finish', () => { | |
let messages = games.slice(-1) | |
io.to(socket.id).emit('finish-2-messages', messages[0]) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express') | |
const bodyParser = require('body-parser') | |
const path = require('path') | |
const app = express() | |
const http = require('http').createServer(app) | |
const io = require('socket.io')(http) | |
const ethereumjs = require('ethereumjs-abi') | |
const ethereumjsUtil = require('ethereumjs-util') | |
const port = 4000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity 0.5.0; | |
contract Example { | |
uint256 counter; | |
modifier onlyOwner {} | |
constructor() {} | |
function doSomething() {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('babel-polyfill') | |
const html = require('html-webpack-plugin') | |
const path = require('path') | |
module.exports = { | |
entry: ['babel-polyfill', './src/index.js'], | |
output: { | |
filename: 'bundle.js', | |
path: path.join(__dirname, 'dist') | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" dir="ltr"> | |
<head> | |
<meta charset="utf-8"> | |
<title><%= htmlWebpackPlugin.options.title %></title> | |
</head> | |
<body> | |
<div id="root"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import ReactDOM from 'react-dom' | |
import './index.css' | |
class Main extends React.Component { | |
constructor() { | |
super() | |
} | |
render() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": [ | |
"@babel/preset-env", | |
"@babel/preset-react" | |
] | |
} |