Skip to content

Instantly share code, notes, and snippets.

View merlox's full-sized avatar
😄
Building great things together!

merlox merlox

😄
Building great things together!
View GitHub Profile
0x7461CCF1FD55c069ce13E07D163C65c78c8b48D1
@merlox
merlox / Rinkeby
Created September 16, 2018 16:18
0x5912d3e530201d7b3ff7e140421f03a7cdb386a3
let Contract
let contractInstance
let contractAddress
function start() {
document.querySelector('#new-game').addEventListener('click', () => {
...
})
document.querySelector('#join-game').addEventListener('click', () => {
...
})
@merlox
merlox / index.js
Created September 25, 2018 20:57
This is how the index.js file looks like
function start() {
document.querySelector('#new-game').addEventListener('click', () => {
const classNewGameBox = document.querySelector('.new-game-setup').className
// Toggle hidden box to display it or hide it
if(classNewGameBox === 'new-game-setup') {
// To hide the box
document.querySelector('.new-game-setup').className = 'hidden new-game-setup'
document.querySelector('#button-continue').className = 'hidden'
document.querySelector('#join-game').disabled = false
} else {
const abi = [
{
"constant": true,
"inputs": [],
"name": "player2Escrow",
"outputs": [
{
"name": "",
"type": "uint256"
}
const abi = [
{
"constant": true,
"inputs": [],
"name": "player2Escrow",
"outputs": [
{
"name": "",
"type": "uint256"
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="index.css">
<title>Dice ethereum game</title>
</head>
<body>
<div class="main-content">
<h1>Ethereum Dice</h1>
Contract = web3.eth.contract(abi)
contractInstance = Contract.new({
value: web3.toWei(valueSelected),
data: bytecode.object,
gas: 7e6
}, (err, result) => {
// This callback will be called twice, the second time includes the contract address
if(!result.address) {
console.log('wait until the block is mined with the contract creation transaction')
let Contract
let contractInstance
function start() {
document.querySelector('#new-game').addEventListener('click', () => {
const classNewGameBox = document.querySelector('.new-game-setup').className
// Toggle hidden box to display it or hide it
if(classNewGameBox === 'new-game-setup') {
// To hide the box
let Contract
let contractInstance
let escrowPlayer1
let escrowPlayer2
let balancePlayer1
let balancePlayer2
start()
function start() {