# Findings for BattleZips Frontend Frontend Repo : https://github.com/BattleZips/BattleZips-Noir-frontend Subgraph : https://github.com/BattleZips/battlezip-subgraph Contract deployed on polygon mumbai used : https://mumbai.polygonscan.com/address/0xe65c09d82572201684972562062619a2a56e6671#code `NOTE: Both players need to connect their MetaMask wallet and have some testnet MATIC in their wallet for making transactions.` ## Game flow A user start a battleship game by generating a proof and making a SC call: ``` newGame(uint256 _boardHash,bytes _proof) ``` OR ``` joinGame(uint256 _game,uint256 _boardHash,bytes _proof) ``` Sample : https://mumbai.polygonscan.com/tx/0xf0dca0df2bd9bacacbfae2877de125b322f55f906c74480377c688aef420c2a6 ---------------------------------------------------------------- For the user who has generated the game, they have the first turn and submit the move by making a smart contract call. No proof is required for this turn: ``` firstTurn(uint256 _game,uint256[2] _shot) ``` Sample : https://mumbai.polygonscan.com/tx/0xe3bb40614b60dddbda44a5d25a9318e687224ea03eb9104bec00cdfe55526863 ----------------------------------------------------------------- Every subsequent move by any player requires generating a proof and making a smart contract call: ``` turn(uint256 _game,bool _hit,uint256[2] _next,bytes _proof) ``` Sample : https://mumbai.polygonscan.com/tx/0xf2fd2707ddfc32a6b9d73178f89c19c545070e7a4d142fd2d16d6584f53aa2f6 ----------------------------------------------------------------- We can plug in our API for generating proof here : https://github.com/BattleZips/BattleZips-Noir-frontend/blob/master/src/views/BuildBoardView/index.tsx#L178C45-L178C45 ------------------------------------------------------------------ ## Inputs newGame/joinGame board inputs from frontend : ``` { "hash": "0x20c29c67ebd03a88d88e12cbc86d9180f5aa071cd84a459f1304e8e2b5b81742", "ships": [ 8, 0, 1, 2, 1, 0, 1, 5, 0, 6, 5, 1, 3, 9, 0 ] } ``` turn inputs from frontend : ``` { "hash": "0x012bb1bf8be3fc3ea5eb6c2de9cfb6c7c371c60f2254712b3aa4d933ee4a0277", "hit": 0, "ships": [ 8, 1, 1, 3, 1, 1, 1, 6, 0, 6, 7, 0, 2, 8, 1 ], "shot": [ 7, 1 ] } ```