Skip to main content

Get All Markets

Fetch all prediction markets from the EnhancedPredictionMarket contract.
cURL
curl https://proteus-production-6213.up.railway.app/api/chain/markets
status
string
Filter by market status: active, resolved, or all (default: all)
markets
array
Array of market objects fetched from blockchain
total
number
Total number of markets returned
source
string
Always "blockchain" - indicates data source

Response

{
  "markets": [
    {
      "id": 1,
      "actor_address": "0x1234567890abcdef1234567890abcdef12345678",
      "start_time": 1735689600,
      "end_time": 1735776000,
      "status": "active",
      "total_volume": "1500000000000000000",
      "block_number": 12345678,
      "transaction_hash": "0xabcdef..."
    },
    {
      "id": 2,
      "actor_address": "0x9876543210fedcba9876543210fedcba98765432",
      "start_time": 1735603200,
      "end_time": 1735689600,
      "status": "resolved",
      "total_volume": "2500000000000000000",
      "block_number": 12340000,
      "transaction_hash": "0x123456..."
    }
  ],
  "total": 2,
  "source": "blockchain"
}
All market data is queried from MarketCreated events emitted by the smart contract. The API automatically processes event logs and enriches them with current on-chain state.

Get Market Details

Get detailed information about a specific market including submissions and bets.
cURL
curl https://proteus-production-6213.up.railway.app/api/chain/market/1
market_id
number
required
The on-chain market ID
market
object
Detailed market data including submissions and betting statistics
market.id
number
Market ID
market.actor_address
string
Ethereum address of the actor this market is about
market.start_time
number
Unix timestamp when market becomes active
market.end_time
number
Unix timestamp when market closes for predictions
market.status
string
Current status: active, resolved, or cancelled
market.total_volume
string
Total ETH volume in wei (use Web3.utils.fromWei to convert)
market.submissions
array
Array of prediction submissions for this market
market.bet_count
number
Total number of bets placed on this market
market.bet_volume
string
Total ETH bet volume in wei

Response

{
  "market": {
    "id": 1,
    "actor_address": "0x1234567890abcdef1234567890abcdef12345678",
    "start_time": 1735689600,
    "end_time": 1735776000,
    "status": "active",
    "total_volume": "1500000000000000000",
    "submissions": [
      {
        "id": 0,
        "creator": "0xabcdef1234567890abcdef1234567890abcdef12",
        "predicted_text": "Mars is the future of humanity",
        "stake": "100000000000000000",
        "block_number": 12345680
      },
      {
        "id": 1,
        "creator": "0x567890abcdef1234567890abcdef1234567890ab",
        "predicted_text": "The red planet awaits us",
        "stake": "150000000000000000",
        "block_number": 12345685
      }
    ],
    "bet_count": 12,
    "bet_volume": "1250000000000000000"
  },
  "source": "blockchain"
}

Get Platform Stats

Get aggregated statistics across all markets.
cURL
curl https://proteus-production-6213.up.railway.app/api/chain/stats
total_markets
number
Total number of markets created
active_markets
number
Markets currently accepting predictions
resolved_markets
number
Markets that have been resolved
total_volume
string
Total ETH volume across all markets (wei)
total_actors
number
Number of registered actors
genesis_nft_holders
number
Total Genesis NFT supply minted
gas_price
string
Current BASE network gas price (wei)

Response

{
  "total_markets": 150,
  "active_markets": 45,
  "resolved_markets": 98,
  "total_volume": "15000000000000000000000",
  "total_actors": 87,
  "genesis_nft_holders": 63,
  "gas_price": "1000000000",
  "source": "blockchain"
}
Stats aggregation requires querying all market events and can be resource-intensive. This endpoint has a 10-second cache TTL. For high-frequency applications, consider caching the response client-side.

Get Oracle Submissions

Get oracle submissions for a specific market (used for resolution).
cURL
curl https://proteus-production-6213.up.railway.app/api/chain/oracle/submissions/1
market_id
number
required
The market ID to query oracle submissions for
market_id
string
Market ID as string
submissions
array
Array of oracle submissions from DecentralizedOracle contract
submissions[].oracle
string
Address of the oracle node that submitted
submissions[].actual_text
string
The actual text that was posted by the actor
submissions[].source_url
string
URL of the source (e.g., X.com tweet link)
submissions[].timestamp
number
Unix timestamp of oracle submission
total
number
Total number of oracle submissions

Response

{
  "market_id": "1",
  "submissions": [
    {
      "oracle": "0xoracle1234567890abcdef1234567890abcdef1234",
      "actual_text": "Mars is definitely the future of humanity",
      "source_url": "https://x.com/elonmusk/status/1234567890",
      "timestamp": 1735780000,
      "block_number": 12346000,
      "transaction_hash": "0xfedcba9876543210fedcba9876543210fedcba98"
    }
  ],
  "total": 1,
  "source": "blockchain"
}

Market Status Values

StatusDescription
activeMarket is open for predictions
resolvedMarket has been resolved with outcome
cancelledMarket was cancelled (rare)
unknownUnable to determine status from contract

Working with Wei Values

All ETH amounts are returned as strings in wei (1 ETH = 10^18 wei).
JavaScript
import { ethers } from 'ethers';

// Convert wei to ETH
const volumeWei = "1500000000000000000";
const volumeEth = ethers.formatEther(volumeWei);
console.log(volumeEth); // "1.5"

// Convert ETH to wei
const stakeEth = "0.1";
const stakeWei = ethers.parseEther(stakeEth);
console.log(stakeWei); // "100000000000000000"
Python
from web3 import Web3

# Convert wei to ETH
volume_wei = 1500000000000000000
volume_eth = Web3.from_wei(volume_wei, 'ether')
print(volume_eth)  # Decimal('1.5')

# Convert ETH to wei
stake_eth = 0.1
stake_wei = Web3.to_wei(stake_eth, 'ether')
print(stake_wei)  # 100000000000000000

Error Handling

{
  "success": false,
  "error": {
    "code": "SERVICE_UNAVAILABLE",
    "message": "Market contract not available"
  }
}
Common error scenarios:
  • 503 Service Unavailable - Contract not initialized or RPC connection issue
  • 404 Not Found - Market ID does not exist on-chain
  • 500 Blockchain Error - Failed to query contract (check BASE network status)

Build docs developers (and LLMs) love