Skip to content

A decentralized prediction market platform built on Solana, inspired by Polymarket. This project lets users create prediction markets, trade in prediction markets, and settle prediction market outcomes based on real events in a growing prediction market ecosystem.

Notifications You must be signed in to change notification settings

oneandzeros-co/Prediction.fun-Smart-Contract-Solana

 
 

Repository files navigation

Solana Prediction Market Smart Contract

A decentralized prediction market platform built on Solana blockchain, inspired by Polymarket. This project enables users to create markets, trade positions, and resolve outcomes based on real-world events.

Features

  • Market Creation: Create prediction markets for any event
  • Liquidity Provision: Add and withdraw liquidity to markets
  • Trading: Trade positions using Yes/No tokens
  • Market Resolution: Automatic resolution based on final outcomes
  • Fee Structure: Platform and LP fees for sustainable operations

Architecture

The project is built using:

  • Solana Web3.js
  • Anchor Framework
  • SPL Token Program
  • Associated Token Program

Getting Started

Prerequisites

  • Node.js
  • Yarn
  • Solana CLI
  • Anchor Framework

Installation

  1. Clone the repository:
git clone https://github.com/Tru3Bliss/Prediction-Market-Contract-Solana
cd solana-prediction-market
  1. Install dependencies:
yarn install
  1. Build the program:
anchor build

Configuration

Configure your project settings:

yarn script config -e devnet -k <your-keypair-path> -r <your-rpc-url>

Usage Examples

  1. Create a new market:
yarn script market -e devnet -k <your-keypair-path> -r <your-rpc-url>
  1. Add liquidity to a market:
yarn script addlp -y <yes-token-address> -n <no-token-address> -a <amount> -e devnet -k <your-keypair-path> -r <your-rpc-url>
  1. Trade positions:
yarn script swap -y <yes-token-address> -n <no-token-address> -a <amount> -s <style> -t <token-type> -e devnet -k <your-keypair-path> -r <your-rpc-url>
  1. Withdraw liquidity:
yarn script withdraw -y <yes-token-address> -n <no-token-address> -a <amount> -e devnet -k <your-keypair-path> -r <your-rpc-url>
  1. Resolve market:
yarn script resolution -y <yes-token-address> -n <no-token-address> -e devnet -k <your-keypair-path> -r <your-rpc-url>

Example Transactions

Configuration

3PsfbvzAPyhwNPQm2aCTf3XUaJwwrZTCoVVw41uJMzs3DXvx948JUrtW2KQRH1UkoTNFxMSbpN32KF5aFQuZ7mCc

Market Creation

4xnzHarhppyWKJccQh27TUCTyeR2da8JGSXWsKAYw5YvVywKKWJzSz9JxRzNwhuj7fjmrCAhtM2drWc29a8J3i2C

Add Liquidity

3kfdmxfq1U6JKwo7p5aAHQ2QeaF6pxp41ycN2wDTBToujEWQMewSfNpwCSBTLuxFsy1MAUojqfkWkAqAMo63b94k

Withdraw Liquidity

5QDonNfWURYyGrQQwTQWjccsnmRuWSNDb66WuuXo12cWhwXo2SwbvSrRpimXPkAbsSmMzD8iYaoEdf5CgMFdtEk3

Swap

5s9xy2no9YANBCsp8Zr5fBq6whHK65t7eBU3AxLp6xFNcagvvzhpknWrJHrk8BYLfnf4jF6kzeW4QyuZi4UUKQKX

Resolution

TryUfcHXKTVWTY3vM1bUCckbtBCxnHBrbB92LFCpRf67J5po2HsqvPT5wWNYSQJVWBcvcvWbS42KfcX6vufdUup

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

About

A decentralized prediction market platform built on Solana, inspired by Polymarket. This project lets users create prediction markets, trade in prediction markets, and settle prediction market outcomes based on real events in a growing prediction market ecosystem.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 79.9%
  • TypeScript 20.1%