Open-source Solana Prediction Market smart contract built with Anchor
Open-source Solana Prediction Market smart contract built with Anchor. Enables creation of binary YES/NO outcome markets with bonding curve trading (SOL tokens), platform + creator fees, Metaplex metadata, whitelist support, and optional backend co-signing for controlled launches.
I open-sourced solana-prediction-market-smart-contract for developers in Solana / Anchor smart contract development. This post walks through what it does, how the pieces fit together, and how to run it locally.
Live demo / site: https://takes.fun/
Why I built this
- Automate trading or snipe strategies with a typed codebase
- Backtest ideas before deploying with real capital
- Extend the bot with your own risk rules and market filters
Most tutorials stop at a smart contract or a UI mockup. I wanted a complete vertical slice — wallet flow, on-chain logic, backend state, and a responsive frontend — so you can study or fork a production-shaped codebase.
What it does
- Open-source Solana Prediction Market smart contract built with Anchor
- Enables creation of binary YES/NO outcome markets with bonding curve trading (SOL tokens), platform + creator fees, Metaplex metadata, whitelist support, and optional backend co-signing for controlled launches
- Platform fees on buy and sell (standard and reduced “small” fee tiers for whitelisted users).
- Creator fees on buy and sell.
-
Cross-side liquidity shift on buys (configurable
cross_sol_factor), which links YES and NO reserve dynamics. -
amount— Input amount (lamports for buy, token amount for sell depending on direction). -
direction—0= buy,1= sell. -
token_type—0= NO,1= YES.
Architecture at a glance
- On-chain program — Anchor/Rust logic for escrow, rooms, and settlement
- Application layer — TypeScript backend/frontend tying on-chain and off-chain flows
- Feature — Open-source Solana Prediction Market smart contract built with Anchor
- Feature — Enables creation of binary YES/NO outcome markets with bonding curve trading (SOL tokens), platform + creator fees, Metaplex metadata, whitelist support, and optional backend co-signing for controlled launches
- Feature — Platform fees on buy and sell (standard and reduced “small” fee tiers for whitelisted users).
User Wallet → On-chain Program → VRF / Settlement
↓
Backend (API + WebSockets) → MongoDB / state
↓
Frontend UI (real-time)
Adjust the diagram to match your repo layout if components differ.
Tech stack
- Rust
- Solana
- Anchor
- TypeScript
Quick start
git clone https://github.com/DexCrancer/solana-prediction-market-smart-contract.git
cd solana-prediction-market-smart-contract
Setup steps:
- Install dependencies (see README — typically npm install or yarn)
- Copy .env.example to .env and fill in RPC, wallet, and API keys
- Run local validator or point to devnet/mainnet as documented
- Start the backend and frontend; connect wallet and create a test room
See the full README for environment variables, deploy scripts, and test commands: https://github.com/DexCrancer/solana-prediction-market-smart-contract
What to explore in the repo
- Program / contract entrypoints and account models
- API routes and WebSocket event handlers
- Frontend wallet adapter and game room components
- Tests, scripts, and deployment configs
Contributing
Issues and PRs are welcome. If this helped you learn something, a ⭐ on GitHub makes it easier for others to find.
Links
- GitHub: https://github.com/DexCrancer/solana-prediction-market-smart-contract
- Website: https://takes.fun/
Disclaimer: Educational content only. Not financial advice. Gambling and trading involve risk; use responsibly and comply with local laws.
Top comments (0)