Chapter 1: Setup battleship frontend

Since we have built the circuit and the smart contract, the next thing to do is to integrate them into a frontend so users can easily interact with the contract.

Git clone

You can get it with following command:

git clone https://github.com/sCrypt-Inc/zk-battleship

Setup & Run

You can run the following commands to setup and run the project quickly:

curl -Ls https://scrypt.io/scripts/setup-zokrates.sh | sh npm i && npm run setup npm start

If you modify the circuit or sCrypt contract, you need to run the setup command to generate assets again. Otherwise you do not have to run it.

npm run setup

The setup script will:

  1. Compile the circuit and finish the Zokrates setup procedure;
  2. Export an sCrypt verifier using the outcome of the first step
  3. Compile the BattleShip contract (generates an artifact JSON file);
  4. Copy all output files to public folder as assets;

Prerequisites

In order to play the game, you need to:

How to switch to testnet


You can now visit http://localhost:3000 in Chrome browser, or you could try the online version here.

Credits

We build the frontend based on this project.