This project demonstrates the power of GenLayer's Intelligent Contracts through a comprehensive AI-powered prediction markets platform. Unlike traditional prediction markets, this implementation leverages GenLayer's unique capabilities for web data access, AI-driven analysis, and non-deterministic operations to create truly intelligent markets.
AI-Powered Prediction Markets is now live on GenLayer Studio!
- Contract Address:
0x48eE698ffd6d5c0597bC05A13158b851ECf6F3B5 - Network: GenLayer Studio (Chain ID: 61999)
- Deployer:
0x86E95581E41946ED84956433a8a9c836bCbA636c - Studio: https://studio.genlayer.com
See DEPLOYMENT.md for complete deployment details and usage instructions.
- Advanced Prediction Market Contract (
contracts/prediction_market.py) - Multi-category markets with AI-powered resolution - Legacy Football Betting Contract (
contracts/football_bets.py) - Original simple betting example - Modern Vue.js Frontend - Comprehensive UI for market discovery, creation, and trading
- AI Market Maker - Dynamic pricing based on betting volume and sentiment analysis
- Multi-Category Support - Sports, Politics, Entertainment, Economics, Crypto, and more
- Automated Resolution - AI analyzes web data to determine market outcomes
- Comprehensive Tests - Full test coverage for all contract functionality
- 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
Before starting, secure your private keys:
- Copy
keypair.json.exampletokeypair.jsonand add your private key - Never commit
keypair.jsonto git (already in.gitignore) - See DEPLOYMENT.md for secure key management
Deploy the enhanced prediction market contract from /contracts/prediction_market.py:
- Choose the network that you want to use (studionet, localnet, or tesnet-*):
genlayer network - Execute the deploy command
genlayer deploy. This will deploy the PredictionMarket contract located in/contracts/prediction_market.py
Note: The deploy script has been updated to use the new prediction market contract instead of the legacy football betting contract.
- All the content of the dApp is located in the
/appfolder. - Copy the
.env.examplefile in theappfolder and rename it to.env, then fill in the values for your configuration. The provided VITE_STUDIO_URL value is the backend of the hosted GenLayer Studio. - Add the deployed contract address to the
/app/.envunder the variableVITE_CONTRACT_ADDRESS
Execute the following commands in your terminal:
cd app
npm install
npm run devThe terminal should display a link to access your frontend app (usually at http://localhost:5173/). For more information on the code see GenLayerJS.
- Sentiment Analysis: AI analyzes market titles and descriptions to suggest optimal initial odds
- Category Intelligence: Smart categorization with tailored resolution sources
- Dynamic Pricing: Automated market maker adjusts share prices based on betting volume
- Sports: Football, basketball, esports with real-time data integration
- Politics: Elections, policy decisions, geopolitical events
- Entertainment: Award shows, TV series outcomes, celebrity predictions
- Economics: Market movements, inflation predictions, corporate earnings
- Crypto: Price movements, protocol updates, adoption metrics
- Web Data Analysis: AI fetches and analyzes data from specified sources
- Consensus Mechanism: Uses GenLayer's Equivalence Principle for fair resolution
- Automated Payouts: Winners automatically receive proportional rewards
- Market Discovery: Browse and filter markets by category and status
- Position Tracking: Monitor all your active bets and potential returns
- Real-time Updates: Live price updates and market statistics
- Responsive Design: Works seamlessly on desktop and mobile devices
- 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 comprehensive tests for both the legacy football betting system and the new AI-powered prediction markets:
- Market Creation - Test creating markets with different categories and configurations
- Betting System - Test placing bets and share price calculations
- Multi-Category Support - Validate all supported market categories
- AI Integration - Test sentiment analysis and market resolution
- User Management - Test positions tracking and balance management
- Creating a bet
- Resolving a bet
- Querying bets for a player
- Querying points for a player
To run the tests:
# Install dependencies
pip install -r requirements.txt
# Run all tests (requires GenLayer Studio running on localhost:4000)
gltest- Connect Wallet: Click "Connect Wallet" to create a new GenLayer account
- Choose Template: Browse market templates or create from scratch
- Fill Details: Add title, description, outcomes, and resolution source
- Deploy: Submit the transaction to create your market
import { GenLayerClient } from './services/genlayer.js'
// Create a simple yes/no market
const marketId = await GenLayerClient.createMarket({
title: "Will Bitcoin reach $100K in 2025?",
description: "Market resolves based on Bitcoin price at end of 2025",
category: "crypto",
resolution_date: "2025-12-31",
resolution_source: "https://coinmarketcap.com/",
outcomes: ["Yes", "No"],
min_stake_eth: "0.01"
})// Bet 0.1 ETH on "Yes" outcome
await GenLayerClient.placeBet(marketId, "outcome_1", "100000000000000000")// Markets resolve automatically using AI analysis of web data
await GenLayerClient.resolveMarket(marketId)- Football: NFL, college football, international soccer
- Basketball: NBA, NCAA, international leagues
- Other Sports: Baseball, hockey, tennis, esports
- Elections: Presidential, congressional, local elections
- Policy: Legislative votes, regulatory decisions
- International: Brexit, trade deals, diplomatic events
- Awards: Oscars, Emmys, Grammy predictions
- Box Office: Movie performance, streaming success
- TV/Streaming: Series renewals, ratings predictions
- Stock Performance: Individual stocks, indices, sectors
- Economic Indicators: GDP, inflation, employment
- Corporate: Earnings, mergers, product launches
- Price Predictions: Bitcoin, Ethereum, altcoins
- Protocol Updates: Hard forks, major releases
- Adoption Metrics: Institutional adoption, regulatory approval
- Sentiment Analysis: AI evaluates market sentiment and suggests optimal initial odds
- Category-Specific Intelligence: Tailored analysis for sports, politics, entertainment, etc.
- Risk Assessment: Automated evaluation of market volatility and complexity
- Dynamic Pricing: Share prices adjust automatically based on betting volume and AI analysis
- Web Data Integration: AI fetches and analyzes data from specified sources
- Multi-Source Verification: Cross-references multiple data sources for accuracy
- Consensus Mechanism: Uses GenLayer's Equivalence Principle for fair resolution
- Evidence Documentation: Provides clear reasoning for resolution decisions
- Volume-Based Pricing: Prices adjust based on betting activity
- Liquidity Optimization: Maintains healthy market liquidity
- Anti-Manipulation: Detects and prevents market manipulation attempts
- Written in Python for GenLayer's Intelligent Contract platform
- Leverages GenLayer's LLM integration for AI-powered analysis
- Web data access for real-world information integration
- Non-deterministic operations for complex decision making
- Modern Vue.js 3 application with Composition API
- Responsive design with Tailwind CSS
- Real-time market updates and position tracking
- Integrated wallet management with GenLayerJS
- Category-specific market analysis prompts
- Automated data fetching and parsing
- Consensus-based resolution system
- Market sentiment and volatility assessment
- Advanced Trading: Limit orders, stop losses, market making
- Social Features: Market discussions, follower systems, leaderboards
- Mobile App: Native iOS and Android applications
- API Integration: Real-time data feeds for sports, finance, and news
- Governance Token: Community-driven platform governance
- Cross-Chain Support: Multi-blockchain market creation and settlement
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.