Skip to main content

Overview

Predict.fun is a prediction market platform with API key and Ethereum wallet authentication.
FeatureStatus
REST APIFull Support
WebSocketNot Supported
AuthenticationAPI Key + Ethereum Wallet
EnvironmentProduction & Testnet

Configuration

Testnet Setup

use pc_exchange_predictfun::{PredictFun, PredictFunConfig};

// Use testnet for development
let config = PredictFunConfig::testnet();
let exchange = PredictFun::new(config)?;

Production Setup

use pc_exchange_predictfun::{PredictFun, PredictFunConfig};

let config = PredictFunConfig::new()
    .with_api_key("your-api-key")
    .with_private_key("0x...");

let exchange = PredictFun::new(config)?;

Full Configuration

use pc_exchange_predictfun::{PredictFun, PredictFunConfig};

let config = PredictFunConfig::new()
    .with_api_key("your-api-key")
    .with_private_key("0x...")
    .with_verbose(true);

let exchange = PredictFun::new(config)?;

Environment Variables

export PREDICTFUN_API_KEY="your-api-key"
export PREDICTFUN_PRIVATE_KEY="0x..."

Examples

Fetch Markets

use pc_core::{Exchange, FetchMarketsParams};
use pc_exchange_predictfun::{PredictFun, PredictFunConfig};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Use testnet if no API key
    let config = match std::env::var("PREDICTFUN_API_KEY") {
        Ok(key) => PredictFunConfig::new().with_api_key(&key),
        Err(_) => PredictFunConfig::testnet(),
    };

    let exchange = PredictFun::new(config)?;

    let markets = exchange
        .fetch_markets(Some(FetchMarketsParams {
            limit: Some(10),
            active_only: true,
        }))
        .await?;

    for market in markets {
        println!("─────────────────────────────────");
        println!("ID: {}", market.id);
        println!("Question: {}", market.question);
        println!("Volume: ${:.0}", market.volume);
    }

    Ok(())
}

Place an Order

use pc_core::{Exchange, OrderSide};
use std::collections::HashMap;

let config = PredictFunConfig::new()
    .with_api_key("your-api-key")
    .with_private_key("0x...");

let exchange = PredictFun::new(config)?;

let order = exchange
    .create_order(
        "market-id",
        "Yes",
        OrderSide::Buy,
        0.50,
        100.0,
        HashMap::new(),
    )
    .await?;

println!("Order: {} - {:?}", order.id, order.status);

Testnet vs Production

AspectTestnetProduction
Auth RequiredNoYes
Real MoneyNoYes
Use CaseDevelopmentLive Trading
// Testnet - for development
let testnet = PredictFun::new(PredictFunConfig::testnet())?;

// Production - requires authentication
let production = PredictFun::new(
    PredictFunConfig::new()
        .with_api_key("...")
        .with_private_key("...")
)?;

Next Steps