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.
DecentralizedPredict 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
- 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
│ └── README.md
├── frontend/ # Next.js frontend application
│ ├── src/
│ │ ├── app/ # Next.js app router pages
│ │ ├── components/ # React components
│ │ ├── providers/ # Context providers
│ │ └── utils/ # Utility functions
│ ├── package.json
│ └── README.md
├── contracts/ # Anchor smart contracts
│ ├── programs/
│ │ └── prediction/ # Rust program source
│ ├── tests/ # Contract tests
│ ├── package.json
│ └── README.md
├── .github/ # GitHub templates and workflows
│ ├── ISSUE_TEMPLATE/ # Issue templates
│ └── workflows/ # CI/CD workflows
├── LICENSE # ISC License
├── CONTRIBUTING.md # Contribution guidelines
└── README.md # This file
- 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/novustch/Prediction-Market.git
cd Prediction-Marketcd backend
npm install
# or
yarn installcd ../frontend
npm install
# or
yarn installcd ../contracts
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 contracts/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 contracts
# 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 contracts
anchor testCurrently, backend tests are not configured. You can add test scripts to backend/package.json.
This project is licensed under the ISC License - see the LICENSE file for details.
Contributions are welcome! Please read our Contributing Guidelines for details on our code of conduct and the process for submitting pull requests.
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
- Telegram: @novustch
- Twitter/X: @novustch
Built with: