mirror of
https://github.com/luxfhe/example-rps-game.git
synced 2026-10-30 18:13:18 +00:00
- Update to unified FHE decryption API - Update dependencies to @luxfi/contracts - Note: TypeScript types pending for @luxfhe/sdk/web
2.4 KiB
2.4 KiB
🔐 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.
