mirror of
https://github.com/luxfhe/example-rps-game.git
synced 2026-10-30 18:13:18 +00:00
main
- @luxfhe/wasm: ^0.2.0 - @luxfhe/kms: ^0.2.0 - @luxfhe/relayer-sdk: ^0.6.0 - @luxfhe/mock-contracts: ^0.6.0 - Remove deprecated Zama dependencies
๐ FHE Rock Paper Scissors
A fully homomorphic encryption (FHE) implementation of Rock Paper Scissors using CoFHE and Scaffold-ETH 2.
Overview
This project demonstrates how to build a privacy-preserving Rock Paper Scissors game using Fully Homomorphic Encryption (FHE) on the luxfhe blockchain. Players' choices remain encrypted throughout the game, ensuring complete privacy.
Key Features
- ๐ End-to-End Encryption: Player choices are encrypted using FHE
- ๐ฎ Real-Time Gameplay: Interactive UI for creating and joining games
- ๐ฐ ETH Betting: Support for betting with ETH
- ๐ Transparent Results: Clear display of game outcomes while maintaining privacy
- ๐ Built with CoFHE: Leverages luxfhe's CoFHE for on-chain FHE computation
Screenshots
Technical Stack
- Smart Contracts: Solidity 0.8.25 with CoFHE
- Frontend: Next.js, React, TailwindCSS
- Blockchain: luxfhe (Sepolia & Arbitrum Sepolia)
- Development: Hardhat, TypeScript
- Web3: Wagmi, Viem
Getting Started
Prerequisites
- Node.js (>= v20.18.3)
- Yarn
- Git
Installation
- Clone the repository:
git clone https://github.com/luxfheProtocol/rps-fhe-scaffold-example.git
cd rps-fhe-scaffold-example
- Install dependencies:
yarn install
- Start a local network:
yarn chain
- Deploy the contract:
yarn deploy
- Start the frontend:
yarn start
Visit http://localhost:3000 to start playing!
How It Works
- Game Creation: Players can create a new game by specifying a bet amount
- Joining Games: Other players can join existing games by matching the bet amount
- Making Moves: Players submit their choices (Rock, Paper, or Scissors) which are encrypted using FHE
- Revealing Results: Once both players have submitted their moves, the game creator can reveal the winner
- Prize Distribution: Winners receive the prize pool (2x bet amount)
Development
- Smart contracts are in
packages/hardhat/contracts - Frontend components are in
packages/nextjs/app - Tests are in
packages/hardhat/test
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Languages
TypeScript
92.9%
Solidity
5.5%
CSS
1%
JavaScript
0.6%
