An open API service indexing awesome lists of open source software.

https://github.com/yllvar/bitvm-prediction

BitVM Prediction Market is a decentralized prediction market built on Bitcoin using Taproot and MAST. It allows two parties to bet on a binary outcome (e.g., "BTC > $200K by 2026") with disputes settled trustlessly on Bitcoin.
https://github.com/yllvar/bitvm-prediction

bitcoin bitvm defi prediction-markets

Last synced: 4 months ago
JSON representation

BitVM Prediction Market is a decentralized prediction market built on Bitcoin using Taproot and MAST. It allows two parties to bet on a binary outcome (e.g., "BTC > $200K by 2026") with disputes settled trustlessly on Bitcoin.

Awesome Lists containing this project

README

          

# ๐ŸŒŸ BitVM Prediction Market

## ๐ŸŽฏ What Is This?

You can bet with a friend on whether Bitcoin will hit $200K by 2026. Normally, Bitcoin can't do complex logic like this. But with **BitVM**, we made it possible while keeping Bitcoinโ€™s secure blockchain as the final judge.

## ๐Ÿ” Why This Matters

Bitcoin is amazing at security and decentralization but not great at running smart contracts. With BitVM, we unlock **Turing-complete logic** โ€” all without changing Bitcoin itself.

### ๐Ÿ’ก Use Case
- Bet on real-world outcomes (e.g., "BTC > $100K?")
- No trust needed โ€” Bitcoin enforces the rules
- Only disputes go on-chain โ€” saves fees!

## ๐Ÿ› ๏ธ How It Works

Here's the magic:

```mermaid
graph TD
A[Alice Bets 'YES'] -->|Locks Funds| C(๐Ÿ“œ Smart Contract)
B[Bob Bets 'NO'] -->|Locks Funds| C
O[๐Ÿ”ฎ CoinGecko Oracle] -->|Reports Price| C
C -->|If Both Agree| D[๐Ÿ’ฐ Automatic Settlement]
C -->|If Dispute| E[โš–๏ธ Bitcoin Decides]
```

### โœจ Core Components

- **๐Ÿ”‘ Key Management:** Alice, Bob, and an Oracle each have keys.
- **๐Ÿ“œ Contracts:** Built using Taproot + MAST to hide complexity until needed.
- **๐Ÿ’ฐ Transactions:** PSBT-based funding and settlement.
- **๐Ÿ” Oracle:** Gets Bitcoin price from CoinGecko.
- **โš–๏ธ Disputes:** If someone cheats, BitVM runs fraud proofs on Bitcoin.

## ๐Ÿ“ฆ Files Overview

```
/bitvm-prediction-market
โ”œโ”€โ”€ .env # Configuration values
โ”œโ”€โ”€ keys.js # Generate participant keys
โ”œโ”€โ”€ oracle.js # Fetch BTC price
โ”œโ”€โ”€ contract.js # Build BitVM scripts & Taproot address
โ”œโ”€โ”€ wallet.js # Create funding/settlement transactions
โ”œโ”€โ”€ dispute.js # Handle disputes via Bitcoin Script
โ”œโ”€โ”€ test.js # Run full workflow simulation
โ””โ”€โ”€ cli.js # User-friendly CLI interface
```

## ๐Ÿš€ Quick Start

### Prerequisites

- Node.js installed
- `.env` file configured (see below)

### Setup Instructions

```bash
# Clone the repo
git clone https://github.com/yllvar/BitVM-Prediction.git
cd BitVM-Prediction

# Install dependencies
npm install

# Run tests
node test.js

# Or use the CLI
node cli.js
```

### Example `.env` File

```env
NETWORK=testnet
ORACLE_PRIVATE_KEY=cQqV9FJ2GzvXHwv5yXr2YRYC5xHk2Z4XH6oRjv8J4HJ9Xu3GfZ8
COINGECKO_API_URL=https://api.coingecko.com/api/v3/simple/price
```

## โš™๏ธ Features

- **๐Ÿ” Bitcoin Security**: Even if someone tries to cheat, Bitcoin ensures fairness.
- **๐Ÿ’ธ Cheap & Efficient**: Only disputed bets touch the blockchain.
- **๐Ÿค– No Trust Needed**: Rules are enforced by code and Bitcoin.
- **๐Ÿ•ต๏ธ Hidden Complexity**: Dispute logic stays off-chain until needed.

## ๐Ÿงช Test Results

When we tested it:

| Action | Result | Time |
|--------|--------|------|
| Created Bet | Alice and Bob locked funds | 2 sec |
| Checked Price | Got $104,327 from CoinGecko | 1 sec |
| Settled Bet | Alice won automatically | 5 sec |
| Simulated Dispute | Bitcoin enforced the rules | ~30 min (on testnet) |

## ๐ŸŒ Technologies Used

- **BitVM**: Off-chain computation with on-chain verification
- **Taproot & MAST**: Hide complex scripts until needed
- **PSBT**: Safe transaction building
- **Schnorr Signatures**: Compact, efficient signatures
- **CoinGecko API**: Real-time price data

## ๐Ÿš€ Future Roadmap

- ๐Ÿ‘ฅ Add multi-party support (N-of-N multisig)
- ๐ŸŒ Integrate decentralized oracles (like Chainlink)
- ๐Ÿ’ป Build a web UI for non-technical users
- ๐Ÿ•ต๏ธ Implement watchtowers to prevent cheating

## ๐Ÿ“š Want More?

Check out the [**ABSTRACT.md**](ABSTRACT.md) file for deeper technical insights, architecture diagrams, and how BitVM opens the door to DeFi, NFTs, and more on Bitcoin.

---

**๐Ÿ’ก The Big Idea**: We proved that **Bitcoin can run complex apps** without compromising its core values โ€” security, simplicity, and decentralization.