ICON Workshop SF Blockchain Week

During SF Blockchain Week, ICON held a workshop building an entire ICON DAPP from scratch, for those of you who didn’t get the chance to attend, we’ll go over the materials here.

The presented DAPP is ICON Dice Roll, but it is really a coin flip game. The application logic is much the same, it takes a predefined input to compare against the generated result. In a coin flip game, there are 2 possible outcomes, heads or tails. In a real dice roll, there are 6 possible outcomes from 1 to 6 for each side. In the Ethereum casino game Ethroll, there are 100 possible outcomes from 1 to 100. With minor tweaks, this DAPP can work like a real dice roll or Ethroll game.

By the end of this tutorial, you’ll build a functional betting DAPP on the ICON network, let’s get started!

# Create a new environment for this DAPP project

$ mkdir WORKSHOP && cd WORKSHOP

$ pwd

# .../icon-tutorial/WORKSHOP

$ git clone

$ cd icon-dice-roll # First clone the workshop project from github$ git clone https://gitlab.com/ibriz/icon-dice-roll.git $ cd icon-dice-roll # Have a glance of the files we cloned

$ ls -1 # 'ICON Workshop Guide.pdf'

# README.md

# config/

# dice-roll/

# keystores/

# testcmdline/

# webapp/

The included ICON Workshop Guide.pdf seems a bit broken in layout and README.md doesn’t contain full instructions, so ignore or delete those. The most up-to-date version of the presentation slide can be found here: ICON Workshop Guide.pdf

The project organized our tbears_cli_config files to the config folder, keystore files to keystores folder and JSON-RPC call json files to testcmdline. The project also built a front end to display results on a web page, using Flask, all under webapp folder.

DiceRoll SCORE

Let’s dig into the SCORE first,

I’ve added more explanations to the source file above, the SCORE is fairly straight forward implementation. It will take ICX transfers (bets), does a coin flip to determine if the bet was won or lost. Winning bets will receive a transfer of 1.98x the betting amount.