https://github.com/risc0/battleship-example
A battleship game using ZKPs
https://github.com/risc0/battleship-example
Last synced: about 2 months ago
JSON representation
A battleship game using ZKPs
- Host: GitHub
- URL: https://github.com/risc0/battleship-example
- Owner: risc0
- Created: 2022-04-12T01:28:46.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-30T03:38:19.000Z (over 1 year ago)
- Last Synced: 2025-04-05T08:35:05.834Z (3 months ago)
- Language: Rust
- Homepage:
- Size: 216 KB
- Stars: 43
- Watchers: 5
- Forks: 7
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Battleship (Rust)
*Edit (Nov 2022): There have been breaking changes to NEAR integration since we built this demo; we're leaving this example up, but builders beware that we're not able to provide a whole lot of support for this example at the moment. Thank you for your understanding.**This README includes instructions to install and play RISC Zero Battleship on your own machine. For more information about RISC Zero Battleship, check out the tutorials at [www.risczero.com](https://www.risczero.com). For questions, find us on [Discord](https://discord.gg/risczero).*
`RISC Zero Battleship` is a 2-player hidden information game implemented in Rust on the NEAR Network.
Players produce proofs of game-state and the result of their actions to enable
two players to play fairly with no intermediaries.## Components
* Web UI (client)
* Prover web service
* NEAR smart contract## Requirements
### Yew
Follow the instructions for [Yew Project Setup](https://yew.rs/docs/getting-started/introduction).
### NEAR
Install the `near-cli`:
```
npm install -g near-cli
```Create a NEAR account: https://wallet.testnet.near.org/create
## Running
Deploy the NEAR smart contract (optional)
```
cd contract
cargo build --release
near dev-deploy target/wasm32-unknown-unknown/release/battleship_contract.wasm
```NOTE: If you deploy your own smart contract, you'll need to update the code to point to this new contract.
See: https://github.com/risc0/battleship-example/blob/main/web/client/near.js#L16
Launch the web service:
```
cargo run --bin battleship-web-server --release
```Launch the web client:
```
cd web/client
trunk serve --open
```## Unit tests
```
cargo test
```## Known issues
- There's an issue with the near javascript API that prevents adjusting the
contract allowance during sign in or when the game starts. This limits each
game to only a few moves regardless of how much NEAR the account had.