Skip to content

KaustubhOG/solana_predication_market

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

Solana Prediction Market

A decentralized prediction market built on Solana using the Anchor framework. It uses a token-splitting model where users split tokens into YES and NO sides, trade them freely, and claim rewards after the winning side is set by a resolver.


What It Does

  • Initializes a prediction market with associated token mints for YES and NO outcomes
  • Allows users to split tokens — depositing base tokens to receive equal YES and NO tokens
  • Allows users to merge tokens — returning equal YES and NO tokens to reclaim base tokens
  • Resolves the market by setting the winning side on-chain
  • Allows winners to claim rewards by redeeming their winning tokens for base tokens

Code Structure

programs/solana_predication_market/src/
├── lib.rs
├── error.rs
├── instructions/
│   ├── mod.rs
│   ├── initialize_market.rs    — creates the market and YES/NO token mints
│   ├── split_tokens.rs         — deposits base tokens, mints equal YES and NO tokens
│   ├── merge_tokens.rs         — burns equal YES and NO tokens, returns base tokens
│   ├── set_winning_side.rs     — resolver sets the winning outcome on-chain
│   └── claim_rewards.rs        — winners redeem winning tokens for base tokens
└── state/
    ├── mod.rs
    └── market_data_struct.rs   — market account: token mints, resolver, winning side

Prerequisites


How to Run

cd solana_predication_market
yarn install
anchor build
anchor test

Make sure your Solana CLI is set to localnet:

solana config set --url localhost

Start a local validator if not already running:

solana-test-validator

About

A simple prediction market on Solana where users bet on outcomes and winners claim rewards after the result is decided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors