This project includes the boilerplate code for a GenLayer use case implementation, specifically a football bets game.
- Basic requirements to deploy and test your intelligent contracts locally
- Configuration file template
- An example of an intelligent contract (Football Bets)
- Example end-to-end tests for the contract provided
- A production-ready Next.js 15 frontend with TypeScript, TanStack Query, and Radix UI
- A running GenLayer Studio (Install from Docs or work with the hosted version of GenLayer Studio). If you are working locally, this repository code does not need to be located in the same directory as the Genlayer Studio.
- GenLayer CLI globally installed. To install or update the GenLayer CLI run
npm install -g genlayer
Deploy the contract from /contracts/football_bets.py using the GenLayer CLI:
- Choose the network that you want to use (studionet, localnet, or tesnet-*):
genlayer network - Execute the deploy command
genlayer deploy. This command is going to execute the deploy script located in/deploy/deployScript.ts
- All the content of the dApp is located in the
/frontendfolder. - Copy the
.env.examplefile in thefrontendfolder and rename it to.env, then fill in the values for your configuration. The provided NEXT_PUBLIC_GENLAYER_RPC_URL value is the backend of the hosted GenLayer Studio. - Add the deployed contract address to the
/frontend/.envunder the variableNEXT_PUBLIC_CONTRACT_ADDRESS
Execute the following commands in your terminal:
Using bun:
cd frontend
bun install
bun devUsing npm:
cd frontend
npm install
npm run devThe terminal should display a link to access your frontend app (usually at http://localhost:3000/). For more information on the code see GenLayerJS.
- Install the Python packages listed in the
requirements.txtfile in a virtual environment. - Make sure your GenLayer Studio is running. Then execute the following command in your terminal:
gltest
The Football Bets contract allows users to create bets for football matches, resolve those bets, and earn points for correct bets. Here's a breakdown of its main functionalities:
-
Creating Bets:
- Users can create a bet for a specific football match by providing the game date, team names, and their predicted winner.
- The contract checks if the game has already finished and if the user has already made a bet for this match.
-
Resolving Bets:
- After a match has concluded, users can resolve their bets.
- The contract fetches the actual match result from a specified URL.
- If the Bet was correct, the user earns a point.
-
Querying Data:
- Users can retrieve all bets.
- The contract also allows querying of points, either for all players or for a specific player.
-
Getting Points:
- Points are awarded for correct bets.
- Users can check their total points or the points of any player.
This project includes integration tests that interact with the contract deployed in the Studio. These tests cover the main functionalities of the Football Bets contract:
- Creating a bet
- Resolving a bet
- Querying bets for a player
- Querying points for a player
The tests simulate real-world interactions with the contract, ensuring that it behaves correctly under various scenarios. They use the GenLayer Studio to deploy and interact with the contract, providing a comprehensive check of the contract's functionality in a controlled environment.
To run the tests, use the gltest command as mentioned in the "Steps to run this example" section.
Connect with the GenLayer community to discuss, collaborate, and share insights:
- Discord Channel: Our primary hub for discussions, support, and announcements.
- Telegram Group: For more informal chats and quick updates.
Your continuous feedback drives better product development. Please engage with us regularly to test, discuss, and improve GenLayer.
For detailed information on how to use GenLayerJS SDK, please refer to our documentation.
This project is licensed under the MIT License - see the LICENSE file for details.