A cross-chain prediction market platform for sports betting with AI-powered odds and real-time data feeds.
- AI-Powered Odds: Machine learning models combined with real-time market data
- Cross-Chain Betting: Bet from Avalanche Fuji using CCIP-BnM tokens on Ethereum Sepolia markets
- Real-Time Updates: Live odds updates periodically
- Multiple Markets: Support for various sports prediction markets
- Multi-Asset Support: ETH and cross-chain token betting
- Frontend: React, Ethers.js, CSS
- Backend: Python Flask, Selenium, OpenAI
- ML: Scikit-learn, Pandas
- Blockchain: Solidity, Ethereum, Avalanche
This project leverages multiple Chainlink services:
File: FunctionsConsumer.sol
Fetches real-time ML-powered odds from external APIs using Chainlink's decentralized compute network.
function requestOdds(
string[] memory args,
uint64 subscriptionId,
uint32 gasLimit
) external onlyOwner returns (bytes32 requestId)File: CCIPBetBridge.sol
Enables cross-chain betting between Avalanche Fuji and Ethereum Sepolia with token transfers with data.
function sendBetWithToken(
uint64 destinationChainSelector,
address receiver,
string calldata eventId,
bool prediction,
address token,
uint256 amount,
bool payWithLINK
) external payable returns (bytes32 messageId)File: contractUtils.js
Frontend integration utilities for Chainlink services including cross-chain betting and Functions interaction.
# Node.js dependencies
npm install ethers react lucide-react
# Python dependencies
pip install flask pandas scikit-learn selenium openai schedule python-dotenv
# Get ngrok tokenCreate .env, new.env file:
CHAINLINK_SUBSCRIPTION_ID=your_subscription_id
OPENAI_API_KEY=your_openai_key
....- Deploy
MarketRegistry.sol - Deploy
FunctionsConsumer.sol - Deploy
PredictionMarketExtended.sol - Deploy
CCIPBetBridge.solon both chains - Configure cross-chain mappings in
config.js
- Start the ML API server:
cd backend
python odds_api.py- Start the real-time data agent:
python agent_real_time_odds.py- Start the frontend:
npm run dev- Start the ngrok tunnel:
ngrok config add-authtoken YOURTOKEN
ngrok http --url=YOURDOMAIN 5001After setting up, run DeployAll_new.s.sol
forge script script/DeployAll_new.s.sol --broadcast --private-key $wallet_private_key
Ethereum Sepolia (ETH):
await predictionMarket.placeBet(prediction, { value: ethAmount });Cross-chain from Avalanche Fuji (CCIP-BnM):
await ccipBridge.sendBetWithToken(
sepoliaSelector, receiver, eventId, prediction, token, amount, true
);Odds are automatically updated via Chainlink Functions:
await functionsConsumer.requestOdds(["Team A vs Team B"], subscriptionId, gasLimit);- Prediction Markets: Main betting contracts
- Chainlink Functions: Odds updates
- Currency: ETH
- CCIP Bridge: Cross-chain betting
- Currency: CCIP-BnM tokens
├── src/
│ ├── PredictionMarketExtended.sol # Main prediction market
│ ├── FunctionsConsumer.sol # Chainlink Functions
│ ├── CCIPBetBridge.sol # Chainlink CCIP
│ └── MarketRegistry.sol # Market discovery
├── script/
│ ├── DeployAll_new.s.sol
│
├── frontend/
│ ├── App.jsx # Main application
│ ├── MarketList.jsx # Market interface
│ ├── contractUtils.js # 🔗 Chainlink utilities
│ └── CountdownTimer.jsx # UI components
└── backend/
├── odds_api.py # ML odds API
├── agent_real_time_odds.py # Data scraping
└── matchPredictionTraining.py # ML model training
POST /odds
Content-Type: application/json
{
"event": "Brazil vs Argentina"
}
Response:
{
"yes": 65,
"no": 35
}
- Allowlisted Chains: CCIP bridges only accept transactions from approved chains
- Sender Validation: Only authorized addresses can trigger cross-chain bets
- Time-Based Controls: Markets automatically close and settle based on timestamps
- Subscription Access: Chainlink Functions protected by subscription model
MIT License - see LICENSE file for details
Powered by Chainlink's decentralized oracle network