MCPcopy
hub / github.com/genlayerlabs/genlayer-project-boilerplate

github.com/genlayerlabs/genlayer-project-boilerplate @v0.2.0 sqlite

repository ↗ · DeepWiki ↗ · release v0.2.0 ↗
107 symbols 304 edges 36 files 7 documented · 7%
README

Sample GenLayer project

License: MIT Discord Telegram Twitter GitHub star chart

👀 About

This project includes the boilerplate code for a GenLayer use case implementation, specifically a football bets game.

📦 What's included

  • 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

🛠️ Requirements

  • 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

🚀 Steps to run this example

1. Deploy the contract

Deploy the contract from /contracts/football_bets.py using the GenLayer CLI: 1. Choose the network that you want to use (studionet, localnet, or tesnet-*): genlayer network 2. Execute the deploy command genlayer deploy. This command is going to execute the deploy script located in /deploy/deployScript.ts

2. Setup the frontend environment

  1. All the content of the dApp is located in the /frontend folder.
  2. Copy the .env.example file in the frontend folder 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.
  3. Add the deployed contract address to the /frontend/.env under the variable NEXT_PUBLIC_CONTRACT_ADDRESS

4. Run the frontend Next.js app

Execute the following commands in your terminal:

Using bun: shell cd frontend bun install bun dev

Using npm: shell cd frontend npm install npm run dev

The terminal should display a link to access your frontend app (usually at http://localhost:3000/). For more information on the code see GenLayerJS.

5. Test contracts

  1. Install the Python packages listed in the requirements.txt file in a virtual environment.
  2. Make sure your GenLayer Studio is running. Then execute the following command in your terminal: shell gltest

⚽ How the Football Bets Contract Works

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:

  1. Creating Bets:
  2. Users can create a bet for a specific football match by providing the game date, team names, and their predicted winner.
  3. The contract checks if the game has already finished and if the user has already made a bet for this match.

  4. Resolving Bets:

  5. After a match has concluded, users can resolve their bets.
  6. The contract fetches the actual match result from a specified URL.
  7. If the Bet was correct, the user earns a point.

  8. Querying Data:

  9. Users can retrieve all bets.
  10. The contract also allows querying of points, either for all players or for a specific player.

  11. Getting Points:

  12. Points are awarded for correct bets.
  13. Users can check their total points or the points of any player.

🧪 Tests

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:

  1. Creating a bet
  2. Resolving a bet
  3. Querying bets for a player
  4. 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.

💬 Community

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.

📖 Documentation

For detailed information on how to use GenLayerJS SDK, please refer to our documentation.

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

Extension points exported contracts — how you extend this code

LogoProps (Interface)
(no doc)
frontend/components/Logo.tsx
EthereumProvider (Interface)
(no doc)
frontend/lib/genlayer/client.ts
BetRowProps (Interface)
(no doc)
frontend/components/BetsTable.tsx
Window (Interface)
(no doc)
frontend/lib/genlayer/client.ts
AddressDisplayProps (Interface)
(no doc)
frontend/components/AddressDisplay.tsx
WalletState (Interface)
(no doc)
frontend/lib/genlayer/WalletProvider.tsx
WalletContextValue (Interface)
(no doc)
frontend/lib/genlayer/WalletProvider.tsx
Bet (Interface)
(no doc)
frontend/lib/contracts/types.ts

Core symbols most depended-on inside this repo

cn
called by 13
frontend/lib/utils.ts
error
called by 10
frontend/lib/utils/toast.ts
getEthereumProvider
called by 8
frontend/lib/genlayer/client.ts
useWallet
called by 7
frontend/lib/genlayer/WalletProvider.tsx
useFootballBetsContract
called by 7
frontend/lib/hooks/useFootballBets.ts
get_bets
called by 7
contracts/football_bets.py
getCurrentChainId
called by 5
frontend/lib/genlayer/client.ts
isOnGenLayerNetwork
called by 5
frontend/lib/genlayer/client.ts

Shape

Function 77
Method 15
Interface 11
Class 4

Languages

TypeScript86%
Python14%

Modules by API surface

frontend/lib/genlayer/client.ts17 symbols
contracts/football_bets.py10 symbols
frontend/lib/contracts/FootballBets.ts9 symbols
frontend/lib/utils/toast.ts8 symbols
frontend/lib/genlayer/WalletProvider.tsx8 symbols
frontend/components/Logo.tsx7 symbols
frontend/lib/hooks/useFootballBets.ts6 symbols
frontend/components/BetsTable.tsx6 symbols
frontend/components/CreateBetModal.tsx5 symbols
test/test_footbal_bet.py4 symbols
frontend/lib/contracts/types.ts4 symbols
frontend/components/AccountPanel.tsx4 symbols

Dependencies from manifests, versioned

@radix-ui/react-dialog1.1.15 · 1×
@radix-ui/react-label2.1.7 · 1×
@radix-ui/react-slot1.2.3 · 1×
@tanstack/react-query5.90.5 · 1×
@types/node24.9.1 · 1×
@types/react19.2.2 · 1×
@types/react-dom19.2.2 · 1×
@wagmi/connectors6.1.3 · 1×
@wagmi/core2.22.1 · 1×
autoprefixer10.4.21 · 1×
class-variance-authority0.7.1 · 1×

For agents

$ claude mcp add genlayer-project-boilerplate \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact