Simeple DApp for free betting on foosball matches results. Implemented as a simple static webpage serving the purpose of UI for the Foosball Chain game with the backend ran as Ethereum smart contracts.
Uses web3.js for blockchain integration and Bootstrap for (crude) styling.
npm
- MetaMask browser extension for injecting a
web3
object with already authenticated Ethereum accounts.
web/index.html
- the entry pointweb/main.js
- the UI logic behind the game, requires methods fromintegration.js
web/integration.js
- the code responsible for integration with the smart contractsweb/abis.js
- ABIs for the smart contracts (extracted to a separate file for readability)
npm install
- install dependencies.- Because MetaMask does not inject
web3
into content accessed byfile:///
the DApp should be ran usingnpm run serve
and accessed from [http://localhost:8000/web/]. - Point MetaMask to
localhost:8545
node and import seed words according to instructions from the smart contracts README. - Deploy and run the smart contracts according to the instruction from their repository.
- Your balance at the beginning should show 0 FOO.
- Click "Register" button and confirm the transaction in MetaMask.
- Click "Refresh" button - your balance at the beginning should now show 1000 FOO.
- Add a match using the form and confirm the transaction in MetaMask.
- Click "Refresh" button - the new match should show on the list.
- Add a few bets for the match - use a separate MetaMask account for each bet to observe the results best. Remember to confirm two transactions in MetaMask for each bet: one for token allowance and the second for actually adding the bet.
- Set the result of the match and confirm the transaction in MetaMask.
- Switch between accounts and click "Refresh" button to observe changes in the token balance.