Prediction Market API

Initialize and manage prediction markets

Prediction Market API

The Prediction Market API provides methods to initialize and manage prediction markets on Solana.

Access

from dflow import DFlowClient
 
client = DFlowClient()
pm_api = client.prediction_market

Methods

initialize_market

Initialize a new prediction market (requires authorization).

def initialize_market(
    event_ticker: str,
    market_ticker: str,
    title: str,
    description: str,
    expiration_time: int,
    user_public_key: str,
    oracle_public_key: str | None = None
) -> PredictionMarketInitResponse

Parameters

ParameterTypeDescription
event_tickerstrParent event ticker
market_tickerstrUnique market ticker
titlestrMarket title
descriptionstrMarket description
expiration_timeintUnix timestamp for expiration
user_public_keystrCreator's public key
oracle_public_keystr | NoneOracle for settlement

Example

import time
 
market = client.prediction_market.initialize_market(
    event_ticker="CRYPTO-2025",
    market_ticker="BTC-100K-JAN",
    title="Will BTC reach $100K by January 2025?",
    description="Resolves YES if Bitcoin reaches $100,000 USD",
    expiration_time=int(time.time()) + 86400 * 30,  # 30 days
    user_public_key=str(keypair.pubkey())
)
 
signature = sign_and_send_transaction(market.transaction, keypair)
print(f"Market created: {market.market_address}")

Types

PredictionMarketInitResponse

class PredictionMarketInitResponse(BaseModel):
    market_address: str
    transaction: str  # Base64 encoded
    yes_token_mint: str
    no_token_mint: str

On this page