A fully decentralized prediction market platform on Solana enabling users to create custom markets, add liquidity, place token-based bets, and automatically resolve outcomes using Switchboard oracles and Anchor smart contracts.
DecentraPredict is an open-source decentralized prediction market built on Solana, allowing users to create, participate, add liquidity, and resolve prediction events using smart contracts.
Bet on real-world outcomes. Earn if you're right. Built for transparency, fairness, and community governance.
- Create Custom Markets – Users can create prediction markets with custom questions and outcomes
- Add Liquidity – Fund markets to increase liquidity and enable betting
- Token-Based Betting – Place bets on "Yes" or "No" outcomes using dynamic token pricing
- Decentralized Smart Contracts – Trustless and transparent market resolution on Solana
- Oracle Integration – Automatic result fetching using Switchboard oracles
- Referral System – Earn rewards through referral links
- User Profiles – Track your betting history and market participation
- Real-time Market Data – View active, pending, and resolved markets
You can reference the guide video here:
create_fund_trading.mp4
---## Tech Stack
- Blockchain: Solana (Devnet/Mainnet)
- Smart Contracts: Anchor Framework 0.29.0 / Rust
- Frontend: Next.js 15.2.1 + React 19 + TailwindCSS 4.0
- Backend: Node.js + Express 5 + TypeScript
- Database: MongoDB
- Oracles: Switchboard
- Wallet Integration: Solana Wallet Adapter (Phantom)
Prediction-Market/
├── BackEnd/ # Backend API server
│ ├── src/
│ │ ├── controller/ # Business logic controllers
│ │ ├── router/ # API routes
│ │ ├── model/ # MongoDB models
│ │ ├── prediction_market_sdk/ # Solana SDK integration
│ │ └── oracle_service/ # Oracle feed management
│ └── package.json
├── FrontEnd/ # Next.js frontend application
│ ├── src/
│ │ ├── app/ # Next.js app router pages
│ │ ├── components/ # React components
│ │ ├── providers/ # Context providers
│ │ └── utils/ # Utility functions
│ └── package.json
└── prediction-market-smartcontract/ # Anchor smart contract
├── programs/
│ └── prediction/ # Rust program source
└── tests/ # Contract tests
- Node.js v18 or higher
- Anchor 0.29.0
- Solana CLI (latest stable version)
- MongoDB (local or MongoDB Atlas)
- Yarn or npm package manager
- Rust (for smart contract development)
git clone https://github.com/BlackSky-Jose/Prediction-market.git
cd Prediction-market-SOLANAcd BackEnd
npm install
# or
yarn installcd ../FrontEnd
npm install
# or
yarn installcd ../prediction-market-smartcontract
npm install
# or
yarn installCreate a .env file in the BackEnd directory:
PORT=9000
DB_URL=your_mongodb_connection_string
PASSKEY=your_passkey
FEE_AUTHORITY=your_fee_authority_public_keyYou can copy from the example file:
cd BackEnd
cp env.example .env
# Then edit .env with your actual valuesThe frontend is configured to connect to Solana Devnet by default. You can modify the RPC endpoint in FrontEnd/src/app/layout.tsx if needed.
The smart contract is configured for Solana Devnet. Check prediction-market-smartcontract/Anchor.toml for configuration details.
cd BackEnd
# Development mode (with hot reload)
npm run dev
# or
yarn dev
# Production mode
npm start
# or
yarn startThe backend server will run on http://localhost:9000 (or the port specified in your .env file).
cd FrontEnd
# Development mode
npm run dev
# or
yarn dev
# Production build
npm run build
npm start
# or
yarn build
yarn startThe frontend will be available at http://localhost:3000.
cd prediction-market-smartcontract
# Build the contract
anchor build
# Deploy to devnet
anchor deploy
# Run tests
anchor testThe backend provides the following API endpoints (all prefixed with /api):
POST /api/market/create- Create a new prediction marketPOST /api/market/add- Add additional market informationPOST /api/market/addLiquidity- Add liquidity to a marketPOST /api/market/betting- Place a bet on a marketPOST /api/market/liquidity- Alternative liquidity endpointGET /api/market/get- Get market data
POST /api/oracle/registFeed- Register a custom oracle feed
POST /api/referral/- Get or generate referral codePOST /api/referral/claim- Claim referral rewards
GET /api/profile/- Get user profile data
- Create Market – A user creates a prediction event with a question (e.g., "Will BTC hit $80k by Dec 2025?")
- Add Liquidity – Users can fund markets to increase liquidity. Once a threshold is reached, betting becomes active.
- Participants Bet – Users place stakes on "Yes" or "No" outcomes by purchasing tokens. Token prices fluctuate based on market probability.
- Locking Period – Market closes at deadline; no more bets are accepted.
- Resolution – Oracle fetches real-world outcome automatically from Switchboard feeds.
- Payout – Winners are rewarded proportionally based on their token holdings.
- Pending – Market created but liquidity threshold not met
- Active – Market is open for betting
- Resolved – Oracle has determined the outcome, winners can claim rewards
The backend uses TypeScript with Express. Key directories:
src/controller/- Business logicsrc/router/- API route definitionssrc/model/- MongoDB schemassrc/prediction_market_sdk/- Solana blockchain interactions
The frontend uses Next.js 15 with the App Router. Key directories:
src/app/- Pages and routessrc/components/- Reusable React componentssrc/providers/- Context providers for global state
The smart contract is written in Rust using the Anchor framework:
programs/prediction/src/- Main program logicprograms/prediction/src/instructions/- Individual instruction handlersprograms/prediction/src/states/- Account state definitions
cd prediction-market-smartcontract
anchor testCurrently, backend tests are not configured. You can add test scripts to BackEnd/package.json.
ISC
If you have any questions or would like a more customized app for specific use cases, please feel free to contact us:
- GitHub: Prediction-market-SOLANA
- Telegram: @blacksky_jose
- Twitter/X: @blacksky_jose
Built with: