Technical Documentation: genlayerlabs/genlayer-project-boilerplate
โน๏ธ Provenance: Multi-Tier Ingestion ยท CodeWiki Reference
Overview (`README.md`)
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 genlayer - GenLayer Studio (for integration tests and deployment): Install from Docs or use the hosted GenLayer Studio
Project Structure
contracts/ # Python intelligent contracts
tests/
direct/ # Fast in-memory tests (no Studio required)
test_create_bet.py # Bet creation logic
test_resolve_bet.py # Bet resolution with web/LLM mocks
test_views.py # Read-only view methods
integration/ # Full tests against GenLayer Studio
test_football_bets.py
fixtures.py # Expected state fixtures
frontend/ # Next.js 15 app (TypeScript, TanStack Query, Radix UI)
deploy/ # TypeScript deployment scripts
gltest.config.yaml # Test runner network configuration
pyproject.toml # Python/pytest configuration
.github/workflows/ # CI pipelineQuick Start
1. Set up Python environment
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt2. Lint your contracts
Run the GenVM linter to catch issues before deployment:
genvm-lint check contracts/football_bets.pyThe 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/ -vDirect mode features used in these tests:
direct_deploy("contracts/file.py")โ deploy contract in memorydirect_vm.sender = addressโ set transaction senderdirect_vm.mock_web(pattern, response)โ mock HTTP/render callsdirect_vm.mock_llm(pattern, response)โ mock LLM responsesdirect_vm.expect_revert("message")โ assert expected failuresdirect_vm.clear_mocks()โ reset mocks between calls
4. Deploy the contract
- Choose your network:
genlayer network - 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 -sThese require GenLayer Studio running (local or hosted).
6. Set up the frontend
- Copy
frontend/.env.exampletofrontend/.env - Add your deployed contract address as
NEXT_PUBLIC_CONTRACT_ADDRESS - Run:
cd frontend
npm install
npm run devThe app will be available at http://localhost:3000/.
How the Football Bets Contract Works
- Creating Bets: Users bet on a football match by providing the game date, teams, and predicted winner.
- 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.
- 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:
- Lint after every contract change
- Run direct tests frequently during development
- 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
Documentation
For detailed information, see our documentation.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Overview (`frontend/README.md`)
GenLayer Football Market
Next.js frontend for GenLayer Football Market - AI-powered football match predictions on GenLayer blockchain.
Setup
- Install dependencies:
Using bun:
bun installUsing npm:
npm install- Create
.envfile:
cp .env.example .env- Configure environment variables:
NEXT_PUBLIC_CONTRACT_ADDRESS- GenLayer Football Betting contract addressNEXT_PUBLIC_STUDIO_URL- GenLayer Studio URL (default: https://studio.genlayer.com/api)
Development
Using bun:
bun devUsing npm:
npm run devOpen http://localhost:3000 in your browser.
Build
Using bun:
bun run build
bun startUsing npm:
npm run build
npm startTech Stack
- Next.js 15 - React framework with App Router
- TypeScript - Type safety
- Tailwind CSS v4 - Styling with custom glass-morphism theme
- genlayer-js - GenLayer blockchain SDK
- TanStack Query (React Query) - Data fetching and caching
- Radix UI - Accessible component primitives
- shadcn/ui - Pre-built UI components
Wallet Management
The app uses GenLayer's account system:
- Create Account: Generate a new private key
- Import Account: Import existing private key
- Export Account: Export your private key (secured)
- Disconnect: Clear stored account data
Accounts are stored in browser's localStorage for development convenience.
Features
- Create Bets: Create football match predictions with team names, game date, and predicted winner (Team 1, Team 2, or Draw)
- View Bets: Real-time bet table with match details, predictions, status, and owners
- Resolve Bets: Bet owners can resolve matches using GenLayer's AI to verify actual results
- Leaderboard: Track top players by points earned from correct predictions
- Player Stats: View your points and ranking in the community
- Glass-morphism UI: Premium dark theme with OKLCH colors, backdrop blur effects, and smooth animations
- Real-time Updates: Automatic data fetching with 3-second polling intervals via TanStack Query
--- METRICS ---
- Files Extracted: 2
- Estimated Token Budget: ~1919 tokens
- Canonical Reference: https://codewiki.google/github.com/genlayerlabs/genlayer-project-boilerplate