Skip to content

Edgadafi/cypherpunk-hackathon2025

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

155 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽฏ PrismaFi - Transparent Prediction Markets on Solana

Transparent, Verifiable, On-Chain. A next-generation prediction market platform built on Solana with full transparency and instant settlements. Every bet, resolution, and payout is verifiable on-chain.

Live Demo Solana Next.js TypeScript


๐ŸŒŸ What Makes PrismaFi Different?

Traditional prediction markets suffer from opacity and trust issues. You never know if odds are manipulated or if your payout will arrive.

PrismaFi changes the game:

  • ๐Ÿ” Full Transparency: Every bet, resolution, and payout is verifiable on-chain
  • โšก Instant Settlements: Claims settle in <1 second with Solana's speed
  • ๐Ÿ’ฐ Ultra-Low Fees: $0.00025 per transaction vs $5-50 on Ethereum
  • ๐Ÿ”— Permissionless: Anyone can create markets without gatekeepers
  • ๐ŸŽจ Beautiful UX: Minimalist-brutalist design with real-time updates

๐Ÿš€ Live Demo

๐Ÿ‘‰ Try it now on Solana Devnet

Quick Start (No Installation):

  1. Install Phantom Wallet
  2. Switch to Solana Devnet
  3. Get free SOL from Solana Faucet
  4. Visit the demo and start trading!

โœจ Features

๐ŸŽฏ Core Trading

  • Create Markets - Anyone can create prediction markets with custom questions
  • Binary Betting - Place bets on Yes/NO outcomes with real SOL
  • Market Resolution - Market creators resolve with the final outcome
  • Claim Winnings - Winners get proportional payouts based on pool distribution
  • Real-Time Odds - Live probability updates as bets come in

๐Ÿ”ฎ NEW: Oracle-Powered Markets (Pyth Network Integration)

  • Trustless Resolution - Markets automatically resolve using real-world price data from Pyth Network
  • Zero Human Intervention - No manual resolution needed, eliminates manipulation risk
  • Instant Settlements - Resolves immediately when market expires with latest price feed
  • Verifiable Outcomes - Anyone can verify the Pyth price feed used for resolution
  • Price Feeds Available:
    • ๐Ÿ“ˆ BTC/USD - Bitcoin price markets
    • ๐Ÿ“Š ETH/USD - Ethereum price markets
    • โšก SOL/USD - Solana price markets
    • ๐Ÿ’ต Stablecoin pairs (USDC, USDT)
    • ๐Ÿช™ Top altcoins (BNB, ADA, MATIC)
  • Flexible Conditions - Set markets for price above/below/equals specific thresholds
  • Real-Time Price Display - See current Pyth price vs your threshold live on market page
  • Auto-Resolve Button - Anyone can trigger resolution after expiry (fully permissionless)

Example Oracle Markets:

  • "Will BTC reach $100,000 by Dec 31, 2025?" โ†’ Auto-resolves YES/NO based on Pyth price
  • "Will ETH stay above $3,500 for next 24 hours?" โ†’ Trustless verification
  • "SOL price above $200 on Jan 1, 2026?" โ†’ Instant settlement at exact time

๐Ÿค– AI-Powered Insights (Swarms Integration)

  • Multi-Agent Analysis - Three specialized AI agents working together
  • SentimentAgent - Analyzes social media sentiment and community discussions
  • DataAgent - Examines historical market patterns and win rates
  • StrategyAgent - Recommends optimal position sizing and confidence levels
  • Actionable Insights - Get AI reasoning, not just recommendations

๐Ÿ”ฎ Oracle Resolution (Pyth Network Integration)

  • Automatic Resolution - Markets resolve automatically based on real-world price data
  • Trustless - No human bias or manipulation possible
  • Instant - Resolves immediately after end time
  • Verifiable - Anyone can verify the oracle price on-chain
  • Price Feeds - Support for BTC/USD, ETH/USD, SOL/USD, and more

๐Ÿ“Š User Experience

  • Personal Dashboard - Track all your bets, stats, and P&L in one place
  • Global Leaderboard - See top traders ranked by win rate, ROI, and profit
  • Activity Feed - Real-time blockchain events (bets, markets, resolutions)
  • Public Profiles - View any user's trading history and performance
  • Social Sharing - Share markets, profiles, and winning bets on Twitter/X

โšก Real-Time System

  • Auto-Refresh - All pages update automatically (configurable intervals)
  • Manual Controls - Refresh button and pause/resume toggle on every page
  • Live Indicators - Visual status showing when data was last updated
  • SSR-Compatible - Works with Next.js server-side rendering

๐Ÿ” Discovery & Filters

  • Search Markets - Find markets by question or description
  • Category Filter - Browse by Crypto, Sports, Politics, Tech, etc.
  • Status Filter - Show active, resolved, or all markets
  • Activity Filter - Filter events by type (bets, markets, resolutions)

๐Ÿ—๏ธ Architecture

Tech Stack

Frontend:

  • Next.js 14 (React 18) - Server & client rendering
  • TypeScript 5.0 - Type safety
  • Tailwind CSS - Styling
  • Lucide Icons - Icon library

Blockchain:

  • Solana (Devnet) - L1 blockchain
  • Anchor 0.30 - Smart contract framework
  • Solana Wallet Adapter - Wallet integration
  • @solana/web3.js - Blockchain interactions

Smart Contract:

  • Rust - Contract language
  • Anchor Framework - Development framework
  • UMA-style resolution - Optimistic oracle pattern
  • Pyth Network - Price oracle integration

AI Layer:

  • Swarms - Multi-agent AI orchestration
  • SentimentAgent - Social media analysis
  • DataAgent - Historical pattern recognition
  • StrategyAgent - Trade recommendations

Oracle Layer:

  • Pyth Network - Real-time price feeds
  • Automatic resolution - Trustless market settlement
  • Multiple price feeds - BTC, ETH, SOL, USDC, and more

Deployment:

  • Vercel - Frontend hosting
  • Solana Devnet - Smart contract deployment
  • Swarms API - AI insights engine
  • Pyth Hermes - Price oracle endpoint

Smart Contract Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Prediction Market Program        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                          โ”‚
โ”‚  Instructions:                           โ”‚
โ”‚  โ”œโ”€ initialize()                         โ”‚
โ”‚  โ”œโ”€ create_market()                      โ”‚
โ”‚  โ”œโ”€ place_bet()                          โ”‚
โ”‚  โ”œโ”€ resolve_market()                     โ”‚
โ”‚  โ””โ”€ claim_winnings()                     โ”‚
โ”‚                                          โ”‚
โ”‚  Accounts:                               โ”‚
โ”‚  โ”œโ”€ GlobalState (singleton)             โ”‚
โ”‚  โ”œโ”€ Market (per market)                 โ”‚
โ”‚  โ””โ”€ Bet (per user per market)           โ”‚
โ”‚                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Frontend Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚            Next.js Frontend              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                          โ”‚
โ”‚  Pages:                                  โ”‚
โ”‚  โ”œโ”€ /markets (10s refresh)              โ”‚
โ”‚  โ”œโ”€ /markets/[id] (5s refresh)          โ”‚
โ”‚  โ”œโ”€ /dashboard (8s refresh)             โ”‚
โ”‚  โ”œโ”€ /leaderboard (15s refresh)          โ”‚
โ”‚  โ”œโ”€ /activity (6s refresh)              โ”‚
โ”‚  โ””โ”€ /profile/[wallet] (12s refresh)     โ”‚
โ”‚                                          โ”‚
โ”‚  Custom Hooks:                           โ”‚
โ”‚  โ”œโ”€ useRealTimeData (polling + state)   โ”‚
โ”‚  โ””โ”€ useAnchorWallet (Solana wallet)     โ”‚
โ”‚                                          โ”‚
โ”‚  Components:                             โ”‚
โ”‚  โ”œโ”€ RealTimeStatus (live indicator)     โ”‚
โ”‚  โ”œโ”€ BinaryTradingInterface (betting)    โ”‚
โ”‚  โ”œโ”€ ResolveMarketInterface (creator)    โ”‚
โ”‚  โ”œโ”€ ClaimWinnings (winners)             โ”‚
โ”‚  โ”œโ”€ MarketAnalyzer (AI insights)        โ”‚
โ”‚  โ””โ”€ ShareProfile/Market/Bet (social)    โ”‚
โ”‚                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
               โ”‚
               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Swarms AI Layer                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                          โ”‚
โ”‚  Multi-Agent Orchestration:              โ”‚
โ”‚  โ”œโ”€ SentimentAgent (social analysis)    โ”‚
โ”‚  โ”œโ”€ DataAgent (historical patterns)     โ”‚
โ”‚  โ””โ”€ StrategyAgent (recommendations)     โ”‚
โ”‚                                          โ”‚
โ”‚  Output:                                 โ”‚
โ”‚  โ”œโ”€ Market sentiment score              โ”‚
โ”‚  โ”œโ”€ Historical win rate analysis        โ”‚
โ”‚  โ”œโ”€ Optimal bet size suggestion         โ”‚
โ”‚  โ””โ”€ Confidence level + reasoning        โ”‚
โ”‚                                          โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฆ Installation & Setup

Prerequisites

  • Node.js 18+ and npm
  • Rust 1.70+ (for smart contract)
  • Solana CLI 1.18+
  • Anchor CLI 0.30+
  • Phantom or Solflare wallet

1. Clone Repository

git clone https://github.com/Edgadafi/cypherpunk-hackathon2025.git
cd cypherpunk-hackathon2025

2. Setup Frontend

cd prediction-market
npm install --legacy-peer-deps
cp .env.example .env.local

Edit .env.local:

NEXT_PUBLIC_SOLANA_NETWORK=devnet
NEXT_PUBLIC_SOLANA_RPC_URL=https://api.devnet.solana.com
NEXT_PUBLIC_PROGRAM_ID=your_deployed_program_id

3. Setup Smart Contract

cd ../prediction-market-latam
anchor build
anchor deploy --provider.cluster devnet

Copy the deployed program ID to your .env.local file.

4. Update IDL

cp target/idl/prediction_market.json ../prediction-market/src/idl/

5. Run Development Server

cd ../prediction-market
npm run dev

Visit http://localhost:3000


๐ŸŽฎ Usage Guide

Creating a Market

  1. Connect your Phantom wallet
  2. Click "Create Market" button
  3. Fill in:
    • Question (e.g., "Will Bitcoin reach $100k in 2025?")
    • Description with resolution criteria
    • Category (Crypto, Sports, Politics, etc.)
    • End date/time
  4. Confirm transaction (~0.01 SOL)
  5. Market goes live immediately!

Placing a Bet

  1. Browse markets on /markets
  2. Click on a market to see details
  3. Choose Yes or No
  4. Enter amount in SOL
  5. Confirm transaction
  6. Your bet appears in your Dashboard

Resolving a Market

  1. Only market creator can resolve
  2. Navigate to your created market after end time
  3. Select the winning outcome (Yes or No)
  4. Confirm resolution transaction
  5. Winners can now claim their winnings

Claiming Winnings

  1. Go to market detail page or Dashboard
  2. If you won, you'll see "Claim Winnings" button
  3. Click to claim your proportional share
  4. Winnings transferred to your wallet
  5. Bet marked as claimed

๐Ÿ”ฎ Using Oracle Markets (NEW!)

Creating an Oracle Market:

  1. Click "Create Market"
  2. Select "๐Ÿ”ฎ Oracle Market" tab
  3. Choose asset (BTC/USD, ETH/USD, SOL/USD, etc.)
  4. Set threshold price (e.g., $100,000 for BTC)
  5. Choose comparison (Above / Below / Equals)
  6. Set end date/time when resolution occurs
  7. Add question and description
  8. Confirm and deploy

Betting on Oracle Markets:

  • Same as standard markets
  • See real-time Pyth price updates
  • Threshold and current price displayed
  • "Would Resolve As" indicator shows prediction

Auto-Resolution:

  1. After end time, market is ready to resolve
  2. Anyone can click "Auto-Resolve with Oracle"
  3. Smart contract fetches Pyth price feed
  4. Compares price vs threshold using your condition
  5. Market resolves YES or NO instantly
  6. Winners claim as usual

Benefits:

  • โœ… No trust in market creator needed
  • โœ… No waiting for manual resolution
  • โœ… Cryptographically verifiable outcome
  • โœ… Zero manipulation risk
  • โœ… Instant settlement

๐Ÿ“Š Key Metrics & Stats

User Stats

  • Total Bets - Number of bets placed
  • Active Bets - Unresolved markets
  • Win Rate - % of bets won
  • Total Wagered - SOL bet across all markets
  • Profit/Loss - Net P&L (won - wagered)
  • ROI - Return on investment %

Market Stats

  • Total Yes/No - Amount bet on each outcome
  • Implied Probability - Current odds (Yes%)
  • Total Volume - Sum of all bets
  • Participants - Unique bettors

Leaderboard Rankings

  • Ranked by total profit (descending)
  • Secondary sort by win rate
  • Shows top 50 traders
  • Updates every 15 seconds

๐Ÿ›ฃ๏ธ Roadmap

โœ… Phase 1: MVP (Complete)

  • Core betting functionality
  • Market creation & resolution
  • User dashboard
  • Real-time updates
  • Social features
  • Leaderboard & activity feed
  • Oracle-powered auto-resolution (Pyth Network) ๐Ÿ†•

๐Ÿšง Phase 2: Enhanced UX (In Progress)

  • Advanced charts & analytics
  • Notification system
  • Mobile app (React Native)
  • Email/SMS alerts
  • Portfolio tracking

๐Ÿ”ฎ Phase 3: Advanced Features (Planned)

  • Scalar Markets - Bet on continuous values
  • Liquidity pools & AMM
  • Conditional markets ("If A then B")
  • Market maker interface
  • API for trading bots

๐Ÿ’ฐ Phase 4: Stablecoins & Multi-Token Support (v2)

  • USDC/USDT Support - Bet using stablecoins for price stability
  • On-Ramp Integration - Direct fiat-to-crypto (Ramp, Moonpay, Transak)
  • Off-Ramp Integration - Convert winnings to fiat
  • SPL Token Program - Support for multiple token types
  • Migration Path - Seamless transition from SOL-only to multi-token
  • Token Selection UI - Choose between SOL, USDC, USDT when betting

๐ŸŒ Phase 5: Mainnet & Growth

  • Solana mainnet deployment
  • Partnerships with data providers
  • Integration with Pyth/Chainlink oracles
  • Mobile app launch
  • Marketing campaign
  • Governance token ($PRISMA)

๐Ÿงช Testing

Manual Testing Checklist

  • Create market with wallet connected
  • Place Yes/No bets on different markets
  • Verify dashboard shows correct stats
  • Resolve market as creator
  • Claim winnings as winner
  • View leaderboard and activity feed
  • Share market/profile on social media
  • Test real-time refresh (pause/resume)

Automated Tests (Coming Soon)

# Frontend tests
npm test

# Smart contract tests
anchor test

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for detailed guidelines.

Quick Start:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript strict mode
  • Use Tailwind for styling
  • Write meaningful commit messages
  • Test on Solana Devnet before PR
  • Update documentation for new features

See also:


๐Ÿ› Known Issues & Limitations

Current Limitations

  • Devnet Only - Not on mainnet yet (use test SOL)
  • SOL-Only Betting - Currently supports only SOL for betting. Stablecoin support (USDC/USDT) planned for v2
  • Binary Markets - Scalar markets coming in Phase 3
  • Manual Resolution - Creator must manually resolve (automation planned via oracles)
  • No Dispute Mechanism - Trust-based resolution (UMA integration planned)
  • No On-Ramp/Off-Ramp - Direct fiat-to-crypto conversion not yet integrated

Planned Fixes (v2)

  • Automated resolution via Pyth Network oracles โœ… (Completed)
  • Stablecoin Support (USDC/USDT) - Bet using stablecoins instead of SOL
  • On-Ramp Integration - Direct fiat-to-crypto via Ramp, Moonpay, etc.
  • Off-Ramp Integration - Convert winnings back to fiat
  • SPL Token Program Integration - Support for multiple token types
  • Dispute mechanism for incorrect resolutions
  • Gas optimization for claim transactions
  • Improved error messages

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • Solana Foundation - For the amazing blockchain infrastructure
  • Anchor Framework - For simplifying smart contract development
  • Vercel - For seamless frontend deployment
  • Cypherpunk Hackathon 2025 - For the opportunity and inspiration

๐Ÿ“ž Contact & Links


๐ŸŽฏ Built for Cypherpunk Hackathon 2025

Project: PrismaFi
Team: Edgadafi
Category: DeFi / Prediction Markets
Blockchain: Solana (Devnet)
Demo: Live on Vercel


๐ŸŒŸ Star this repo if you find it useful!

Made with โค๏ธ for the Solana ecosystem

About

A decentralized prediction market platform on Solana empowering users to forecast real-world events. Focused on transparency & accountability.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors