Where music meets blockchain, and your taste could win you ETH! ๐ถ๐ฐ
Live Demo โข Play Now โข Documentation โข Report Bug
RANKr is a decentralized, autonomous game where players compete by ranking songs on-chain. Submit your favorite tracks, rank them against others, and win ETH if your taste matches the crowd! Built on Ethereum using cutting-edge FHE (Fully Homomorphic Encryption) technology for truly private on-chain voting.
- ๐ต Submit Phase: Players add their favorite songs (artist, title, URL)
- ๐ณ๏ธ Ranking Phase: Pay entry fee (0.0001 ETH) and rank all songs from best to worst
- ๐ Winner Determination: Smart contract uses Borda count to compute the collective ranking
- ๐ฐ Prize Distribution: Player(s) whose ranking matches the final order most closely win the prize pool!
- RankrFHE Contract: Encrypted on-chain voting using Fully Homomorphic Encryption (Zama fhEVM)
- Rankings stay private during the game to prevent manipulation
- Deterministic winner selection using the Borda count algorithm
- All game logic runs autonomously on-chain
- No centralized authority or intermediaries
- Games auto-start and auto-complete when thresholds are met
- Automatic prize pool distribution to winners
- Seamless reset for the next round
- Next.js 15 with React 19 for blazing-fast UI
- RainbowKit for beautiful wallet connections
- Wagmi & Viem for type-safe Ethereum interactions
- Scaffold-ETH 2 for rapid dApp development
- DaisyUI + Tailwind CSS for stunning UI components
- Fully responsive on all devices
- Farcaster Mini App integration
- Social sharing features built-in
| Parameter | Value |
|---|---|
| Entry Fee | 0.0001 ETH |
| Songs per Round | 3 |
| Max Players | 2 (configurable) |
| Ranking Method | Borda Count |
| Prize Pool | 100% of entry fees |
| Winner Criteria | Best match to collective ranking |
- Each player's ranking contributes to a cumulative Borda count
- Final song order is determined by highest scores
- Player rankings are compared position-by-position with the final order
- Player(s) with the most matching positions win
- Prize pool is split equally among winners (with remainder to first winner)
- Solidity ^0.8.24+ - Smart contract language
- Hardhat - Ethereum development environment
- Zama fhEVM - Fully Homomorphic Encryption for Ethereum
- OpenZeppelin - Secure smart contract standards
- Next.js 15 - React framework with App Router
- React 19 - UI library
- TypeScript - Type-safe development
- Wagmi v2 - React Hooks for Ethereum
- Viem - TypeScript Ethereum interface
- RainbowKit - Wallet connection UI
- TanStack Query - Data fetching & caching
- Tailwind CSS - Utility-first CSS
- DaisyUI - Beautiful UI components
- Vercel - Frontend hosting
- Alchemy - RPC provider
- IPFS - Decentralized storage option
- Farcaster SDK - Mini app integration
- Node.js >= v20.18.3
- Yarn v1 or v2+
- Git
- MetaMask or compatible Ethereum wallet
- Clone the repository
git clone https://github.com/yourusername/RANKr.git
cd RANKr- Install dependencies
yarn install- Start local blockchain
yarn chain- Deploy contracts (in a new terminal)
yarn deploy- Start the frontend (in a new terminal)
yarn start- Open your browser
http://localhost:3000
You're ready to play! ๐
RANKr/
โโโ packages/
โ โโโ hardhat/ # Smart contracts & deployment
โ โ โโโ contracts/
โ โ โ โโโ Rankr.sol # Main game contract
โ โ โ โโโ RankrFHE.sol # FHE-enabled contract
โ โ โโโ deploy/ # Deployment scripts
โ โ โโโ test/ # Contract tests
โ โ โโโ hardhat.config.ts
โ โ
โ โโโ nextjs/ # Frontend application
โ โโโ app/ # Next.js App Router
โ โโโ components/ # React components
โ โ โโโ game/ # Game-specific components
โ โ โโโ scaffold-eth/ # Scaffold-ETH components
โ โโโ contracts/ # Contract ABIs & addresses
โ โโโ hooks/ # Custom React hooks
โ โโโ utils/ # Utility functions
โ
โโโ README.md # You are here!
The main game contract with transparent voting.
Key Functions:
addItem(ItemInput)- Submit a song to the roundrankItems(uint8[3])- Submit your ranking (payable)getCurrentItems()- View current songsgetPlayers()- View current playersgetPrizePool()- View current prize poolgetWinners()- View winner addresses
Events:
ItemAdded- Song added to roundRankingSubmitted- Player submitted rankingRoundCompleted- Round ended, winners paidRoundReset- New round started
Advanced contract with encrypted voting using Zama fhEVM.
Additional Features:
- Encrypted vote storage on-chain
- Private ranking submissions
- FHE-based vote counting
- Rankr:
[Contract Address] - Block Explorer: View on Basescan
- Rankr:
[Contract Address] - RankrFHE:
[Contract Address] - Block Explorer: View on Etherscan
Automatically deployed when running yarn deploy
yarn hardhat:testyarn compile# Sepolia
yarn workspace @se-2/hardhat deploy --network sepolia
# Base
yarn workspace @se-2/hardhat deploy --network baseyarn verifyyarn format
yarn lintWelcomeModal- Game introduction & rulesSongsScreen- Song submission interfaceVotingScreen- Ranking interface with drag & dropGameStatusCards- Real-time game statusPrizePoolBanner- Live prize pool display
WinnerOverlay- Winner celebration screenNotWinnerOverlay- Better luck next time screenVotedConfirmationCard- Post-vote confirmation
SongCard- Individual song displaySongTile- Draggable ranking tileAddSongDialog- Song submission form
Edit packages/nextjs/scaffold.config.ts to customize:
- Target networks
- RPC endpoints
- Wallet providers
- Polling intervals
- Core game mechanics
- FHE integration for private voting
- Farcaster Mini App integration
- Social sharing features
- Multi-chain deployment (Optimism, Arbitrum)
- NFT rewards for winners
- Tournament mode with multiple rounds
- Spotify API integration
- DAO governance for game parameters
- Mobile app (React Native)
We love contributions! Whether it's bug fixes, new features, or documentation improvements.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please read CONTRIBUTING.md for details on our code of conduct and development process.
This project is licensed under the MIT License - see the LICENCE file for details.
- Scaffold-ETH 2 - Incredible toolkit for Ethereum development
- Zama - Pioneering FHE technology
- BuidlGuidl - Amazing builder community
- Farcaster - Decentralized social protocol
- All contributors who make this project possible! โค๏ธ
- Twitter: @your_twitter
- Discord: Join our community
- Telegram: RANKr Chat
- Email: your@email.com
RANKr is an experimental dApp. Use at your own risk. Always verify smart contract code before interacting. Never invest more than you can afford to lose.