Build and test web-integrated LLM betting contracts with this boilerplate
Using a football betting game that fetches match results from the web and extracts scores with an AI as an example, this repository demonstrates the workflow from contract creation to deployment. It serves as a starting point that consolidates the code structure and testing methods required to build intelligent contracts on the GenLayer platform. You can run it immediately without complex configuration to understand how the platform works.
Contract structure combining web and LLM
The core logic allows users to input match dates, teams, and a winner to create a bet. Once the match ends, the contract fetches the result from BBC Sport, uses an LLM to extract the score, and verifies it using the equivalence principle. If the prediction is correct, points are accumulated, and users can query personal scores or leaderboards. This example simplifies a real-world use case that requires web access and LLM integration.
Testing strategy for fast feedback
Two testing methods are provided to receive quick feedback during development. These run the contract in memory without GenLayer Studio, mocking web requests and LLM calls to confirm results in approximately a few milliseconds per test. These deploy the contract to an actual GenLayer Studio to verify consensus behavior, serving as end-to-end tests.
Static analysis to catch pre-deployment issues
The GenVM linter identifies common contract issues before deployment. It checks for forbidden imports, non-deterministic calls, incorrect storage types, and missing decorators or return type annotations. It also detects non-deterministic operations outside equivalence principle blocks and applies more than 20 rules. Going through this process reduces errors that might occur during the deployment stage.
Execution environment and getting started
Python 3.12 or higher and the GenLayer CLI are required. Install the CLI globally using the npm install -g genlayer command, set up a Python virtual environment, and install dependencies with pip install -r requirements.txt. GenLayer Studio is needed for integration tests and deployment, which can be used via local installation or a hosted Studio.
When to choose this template
This template is suitable for developers building intelligent contracts on the GenLayer platform for the first time or creating contracts that combine LLMs with web data. If you use AI coding agents, the fast feedback loop provided by the linter and direct mode tests is beneficial for iterative development. It is provided under the MIT license, and in environments without GenLayer Studio, significant development can be done using only direct mode tests and the linter. You must always verify consensus behavior through integration tests before deployment.