Chat Price Bet π²π¬
A Web3 hackathon project for ETHGlobal Buenos Aires 2025 that combines group chat betting with real-time crypto price predictions.
π― Concept
Chat Price Bet is a social betting platform where friends can bet on crypto prices in real-time through XMTP group chats. Users place bets on whether ETH price will go UP or DOWN within 5 minutes, powered by Pyth Networkβs real-time price feeds.
π Hackathon Tracks
This project qualifies for multiple prize tracks:
- XMTP - Best Miniapp in a Group Chat ($2,500) - Group chat betting experience
- Pyth Network - Most Innovative use of Pyth Pull Price Feeds ($10,000) - Real-time price feeds for betting
- Pyth Network - Pyth Entropy Pool Prize ($5,000) - Random number generation for fair betting
π οΈ Tech Stack
- Frontend: Next.js 14, React, TypeScript, Tailwind CSS
- Web3: Wagmi, RainbowKit, ethers.js
- Messaging: XMTP React SDK
- Oracle: Pyth Network (Price Feeds & Entropy)
- Blockchain: Base Sepolia (for testing)
- Smart Contracts: Solidity, Hardhat
π Quick Start
Prerequisites
- Node.js 18+ and npm/yarn
- A Web3 wallet (MetaMask recommended)
- Base Sepolia testnet ETH (get from Base Faucet)
Installation
- Clone and install dependencies:
- Set up environment variables:
Edit .env and add:
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID - Get from WalletConnect Cloud
NEXT_PUBLIC_PYTH_CONTRACT_ADDRESS - Pyth contract on Base Sepolia
NEXT_PUBLIC_PYTH_PRICE_FEED_ID - ETH/USD price feed ID
NEXT_PUBLIC_CONTRACT_ADDRESS - Your deployed contract address
- Compile and deploy smart contracts:
# Compile contracts
npm run compile
# Deploy to Base Sepolia (make sure you have PRIVATE_KEY in .env)
npm run deploy
- Run the development server:
Open http://localhost:3000 in your browser.
π± How It Works
- Connect Wallet: Connect your Web3 wallet using RainbowKit
- Initialize XMTP: Start chatting with friends in group conversations
- Place Bets:
- Choose UP or DOWN prediction
- Set bet amount (0.001 - 1 ETH)
- Wait 5 minutes for price movement
- Resolve Bets: After 5 minutes, resolve your bet using Pyth price feeds
- Win or Lose: Get 2x payout if your prediction is correct!
ποΈ Project Structure
chat-price-bet/
βββ app/ # Next.js app directory
β βββ layout.tsx # Root layout with providers
β βββ page.tsx # Main page
β βββ providers.tsx # Web3 & XMTP providers
βββ components/ # React components
β βββ ChatInterface.tsx # XMTP chat UI
β βββ BettingPanel.tsx # Betting interface
βββ contracts/ # Solidity smart contracts
β βββ PriceBet.sol # Main betting contract
βββ hooks/ # Custom React hooks
β βββ useXMTP.ts # XMTP client hook
β βββ usePythPrice.ts # Pyth price fetching
βββ lib/ # Utilities
β βββ contracts.ts # Contract ABIs
βββ scripts/ # Deployment scripts
βββ deploy.js # Contract deployment
π§ Smart Contract Details
The PriceBet contract:
- Uses Pyth Network for real-time price feeds
- Allows users to bet on price direction (UP/DOWN)
- 5-minute betting window
- Automatic payout calculation (2x for winners)
- Tracks all user bets and history
π Integration Guides
XMTP Integration
- Uses
@xmtp/react-sdk for chat functionality
- Supports group conversations
- Real-time messaging between users
Pyth Network Integration
- Price Feeds: Pull method integration
- Fetch price update data from Pyth Hermes
- Call
updatePriceFeeds on-chain
- Read price using
getPriceNoOlderThan
- Entropy (for future randomness features):
- Generate verifiable random numbers
- Use for fair bet resolution
π¨ Features
- β
Wallet connection with RainbowKit
- β
XMTP group chat integration
- β
Real-time price display (Pyth Network)
- β
Place bets on price direction
- β
View betting history
- β
Resolve bets after time window
- β
Modern, responsive UI
π§ Future Enhancements
π Hackathon Submission Checklist
π€ Team
Built for ETHGlobal Buenos Aires 2025
π License
MIT
π Acknowledgments
- XMTP for decentralized messaging
- Pyth Network for real-time price feeds
- Base for the blockchain infrastructure
- ETHGlobal for organizing the hackathon
Note: This is a hackathon project. For production use, additional security audits and optimizations are recommended.