CeloTrivia is a decentralized trivia game built on the Celo blockchain. Users can create trivia games, participate in them, and win prizes. The app leverages smart contracts to securely manage prize distribution.
- Create and host trivia games
- Participate in trivia games and compete for prizes
- Secure prize distribution using Celo smart contracts
- Interactive user interface
- Frontend: React, Tailwind CSS
- Backend: Node.js, Express, Socket io
- Blockchain: Celo, Solidity
- Smart Contracts: CeloTrivia smart contract
- Libraries: Wagmi, Viem, Ethers.js
- Node.js (v14 or higher)
- npm or yarn
- Celo Wallet
-
Clone the repository:
git clone https://github.com/fraolb/CeloTrivia.git cd CeloTrivia -
Install dependencies:
npm install # or yarn install -
Configure environment variables:
Create a
.envfile in the root directory and add your Celo network and wallet details:NEXT_PUBLIC_CELO_NETWORK=alfajores NEXT_PUBLIC_CELO_RPC_URL=https://alfajores-forno.celo-testnet.org NEXT_PUBLIC_CELO_WALLET_PRIVATE_KEY=your_private_key_here
-
Compile smart contracts:
Navigate to the
smart-contractsdirectory and compile the contracts:cd smart-contracts npx hardhat compile -
Deploy smart contracts:
Deploy the contracts to the Celo network:
npx hardhat run scripts/deploy.js --network alfajores
-
Start the development server:
npm run dev # or yarn devThe app will be available at http://localhost:3000.
- Navigate to the dashboard.
- Click on "Create a New Trivia".
- Fill in the details for the trivia game.
- Add prize money and confirm the transaction with your Celo wallet.
- Navigate to the list of available trivia games.
- Select a trivia game to join.
- Answer the trivia questions within the given time.
- Check the leaderboard to see your ranking and if you won any prizes.
The CeloTrivia smart contract is written in Solidity and deployed on the Celo network. It handles the following:
- Creating trivia games
- Managing participants and their answers
- Distributing prizes to winners
createTriviaGame(): Create a new trivia game.joinTriviaGame(uint256 gameId): Join an existing trivia game.submitAnswer(uint256 gameId, uint256 questionId, string answer): Submit an answer to a trivia question.distributePrizes(uint256 gameId): Distribute prizes to the winners of a trivia game.
Contributions are welcome! Please fork the repository and create a pull request with your changes.
If you find any issues or bugs, please open an issue on the GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to reach out if you have any questions or need further assistance.
Happy coding! 🚀
Maintainer: Fraol Bereket
Contact: fraolbereket@gmail.com