Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

genlayer-project-boilerplate

> 编程语言
Open source

Sample GenLayer project About This project includes the boilerplate code for a GenLayer use case implementation, specifically a football be…

14.5K stars0 likes1 views
WebsiteGitHub

About

Sample GenLayer project About This project includes the boilerplate code for a GenLayer use case implementation, specifically a football be…

Sample GenLayer project

About

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

What's included

  • An example intelligent contract (Football Bets) with web access and LLM integration
  • Direct mode tests — fast, in-memory unit tests with web/LLM mocking (~ms per test)
  • Integration tests — full end-to-end tests against GenLayer Studio
  • Contract linting — static analysis to catch common contract issues before deployment
  • CI pipeline — GitHub Actions workflow for linting and direct tests
  • A production-ready Next.js 15 frontend with TypeScript, TanStack Query, and Radix UI
  • Configuration file template and deployment scripts

Requirements

  • Python >= 3.12
  • GenLayer CLI globally installed: npm install -g genlayer
  • GenLayer Studio (for integration tests and deployment): Install from Docs or use the hosted GenLayer Studio

Project Structure

…

Quick Start

1. Set up Python environment

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

2. Lint your contracts

Run the GenVM linter to catch issues before deployment:

genvm-lint check contracts/football_bets.py

The linter catches:

  • Forbidden imports and non-deterministic calls
  • Invalid storage types (must use TreeMap, DynArray, u256, etc.)
  • Missing decorators and return type annotations
  • Non-deterministic operations outside equivalence principle blocks
  • And 20+ other rules

3. Run direct mode tests

Direct mode tests run contracts in-memory without needing GenLayer Studio. They use mocks for web requests and LLM calls, giving you fast feedback (~milliseconds per test):

pytest tests/direct/ -v

Direct mode features used in these tests:

  • direct_deploy("contracts/file.py") — deploy contract in memory
  • direct_vm.sender = address — set transaction sender
  • direct_vm.mock_web(pattern, response) — mock HTTP/render calls
  • direct_vm.mock_llm(pattern, response) — mock LLM responses
  • direct_vm.expect_revert("message") — assert expected failures
  • direct_vm.clear_mocks() — reset mocks between calls

4. Deploy the contract

  1. Choose your network: genlayer network
  2. Deploy: genlayer deploy (runs the script in /deploy/deployScript.ts)

5. Run integration tests

Integration tests deploy the contract to GenLayer Studio and test with real consensus:

gltest tests/integration/ -v -s

These require GenLayer Studio running (local or hosted).

6. Set up the frontend

  1. Copy frontend/.env.example to frontend/.env
  2. Add your deployed contract address as NEXT_PUBLIC_CONTRACT_ADDRESS
  3. Run:
cd frontend
npm install
npm run dev

The app will be available at http://localhost:3000/.

How the Football Bets Contract Works

  1. Creating Bets: Users bet on a football match by providing the game date, teams, and predicted winner.
  2. Resolving Bets: After the match, the contract fetches results from BBC Sport, uses an LLM to extract the score, and validates via the equivalence principle.
  3. Points: Correct predictions earn points. Users can query their points or the leaderboard.

Testing Strategy

Test Type Command Speed Requires Studio Lint genvm-lint check contracts/*.py ~250ms No Direct pytest tests/direct/ -v ~ms/test No Integration gltest tests/integration/ -v -s ~min/test Yes

Recommended workflow:

  1. Lint after every contract change
  2. Run direct tests frequently during development
  3. Run integration tests before deployment to verify consensus behavior

For AI coding agents (Claude Code, Cursor, etc.), the linter and direct tests provide the fast feedback loop needed for iterative development without requiring a running Studio instance.

Community

  • Discord: Discussions, support, and announcements
  • Telegram: Informal chats and quick updates

Documentation

For detailed information, see our documentation.

License

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

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •An example intelligent contract (Football Bets) with web access and LLM integration
  • •Direct mode tests — fast, in-memory unit tests with web/LLM mocking (~ms per test)
  • •Integration tests — full end-to-end tests against GenLayer Studio
  • •Contract linting — static analysis to catch common contract issues before deployment
  • •CI pipeline — GitHub Actions workflow for linting and direct tests
  • •A production-ready Next.js 15 frontend with TypeScript, TanStack Query, and Radix UI
  • •Configuration file template and deployment scripts
  • •Python >= 3.12
  • •GenLayer CLI globally installed: npm install -g genlayer
  • •GenLayer Studio (for integration tests and deployment): Install from Docs or use the hosted GenLayer Studio

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言