A decentralized coin flip game built on the Nexus blockchain. This application allows users to place bets and engage in a simple yet exciting betting game, leveraging the power of smart contracts and the unique features of the Nexus ecosystem.
- Overview
- Features
- Getting Started
- Project Structure
- Installation
- Usage
- Smart Contract
- Contributing
- License
The Nexus Coinflip DApp is designed to provide a fun and engaging way for users to interact with the Nexus blockchain. Players can place bets on the outcome of a coin flip, with the potential for payouts based on their bets. The app showcases the capabilities of the Nexus Layer 1 blockchain and zkVM technology.
-
Smart Contract Functionality:
- Validates bets against predefined amounts.
- Randomized outcomes using secure methods.
- Payout mechanism for winning bets.
- Owner controls for fund management.
-
User-Friendly Frontend:
- Wallet connection and network switching.
- Display of dealer and user balances.
- Real-time feedback on bet outcomes.
- Transaction tracking with links to the Nexus blockchain explorer.
To get started with the Nexus Coinflip DApp, follow the instructions below to set up the project locally.
The project is organized into two main workspaces:
- contracts: Contains the smart contract code and deployment scripts.
- frontend: Contains the React application for the user interface.
-
Clone the repository:
git clone https://github.com/baihaqism/nexus-coinflip-dapp.git cd nexus-coinflip-dapp
-
Install dependencies: Make sure you have Node.js installed. Then run:
npm install
-
Deploy the Smart Contract: Navigate to the
contracts
directory and deploy the smart contract to the Nexus network:npm run deploy
-
Start the Frontend: Navigate to the
frontend
directory and start the development server:npm run frontend
-
Open your browser: Navigate to
http://localhost:3000
to access the application. -
Connect your wallet: Use a compatible wallet (like Rabbit) to connect to the Nexus network.
-
Place your bets: Select a valid bet amount and click "Flip Coin" to participate in the game.
The smart contract for the coin flip game is located in the contracts
directory. It implements the core logic for betting, determining outcomes, and managing funds.
flip()
: Allows users to place a bet and flip the coin.withdraw(uint256 amount)
: Allows the owner to withdraw a specified amount.withdrawAll()
: Allows the owner to withdraw all funds from the contract.getBalance()
: Returns the current balance of the contract.
Contributions are welcome! If you would like to contribute to the Nexus Coinflip DApp, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your changes to your forked repository.
- Create a pull request to the main repository.
This project is licensed under the MIT License. See the LICENSE file for details.
Thank you for checking out the Nexus Coinflip DApp! We hope you enjoy playing and exploring the capabilities of the Nexus blockchain.