Skip to main content

Contract Overview

The DelphAI contract provides an AI-powered resolution oracle for prediction markets. Platforms can create markets on DelphAI by paying a creation fee, and the AI resolver will automatically resolve them at the scheduled time. Contract Address: 0xA95E99848a318e37F128aB841b0CF693c1f0b4D1 (BSC Mainnet)

Market Functions

createMarket

Create a new prediction market with AI resolution.
function createMarket(
    string memory question,
    string memory description,
    string[] memory possibleOutcomes,
    uint256 resolutionTimestamp
) external payable returns (uint256 marketId);
Parameters:
  • question - The market question
  • description - Additional context and resolution criteria
  • possibleOutcomes - Array of possible outcome strings (minimum 2)
  • resolutionTimestamp - Unix timestamp when AI should resolve the market
Returns:
  • marketId - Unique identifier for the created market
Requirements:
  • msg.value must be greater than or equal to marketCreationFee
  • question must not be empty
  • possibleOutcomes must have at least 2 options
  • resolutionTimestamp must be in the future
Example:
uint256 fee = delphAI.marketCreationFee();

string[] memory outcomes = new string[](2);
outcomes[0] = "Yes";
outcomes[1] = "No";

uint256 marketId = delphAI.createMarket{value: fee}(
    "Will BTC reach 100k by December 31, 2025?",
    "Market resolves YES if Bitcoin is above 100k USD",
    outcomes,
    1735689599
);
Emits: MarketCreated event

resolveMarket

Resolve a market with AI-generated outcome (only resolver).
function resolveMarket(
    uint256 marketId,
    uint256 outcomeIndex,
    string memory resolutionData,
    string[] memory resolutionSources,
    uint8 resolutionConfidence,
    bytes memory proofData
) external;
Parameters:
  • marketId - The market to resolve
  • outcomeIndex - Index of the winning outcome in possibleOutcomes array
  • resolutionData - AI explanation and reasoning for the resolution
  • resolutionSources - Array of source URLs used for resolution
  • resolutionConfidence - Confidence level of the resolution (0-100)
  • proofData - TEE attestation or cryptographic proof (future feature)
Requirements:
  • Only callable by authorized resolver address
  • Market must exist and be in Open status
  • Current time must be greater than or equal to resolutionTimestamp
  • outcomeIndex must be valid
  • resolutionConfidence must be between 0 and 100
Emits: MarketResolved event

cancelMarket

Cancel an open market (only creator or owner).
function cancelMarket(uint256 marketId) external;
Parameters:
  • marketId - The market to cancel
Requirements:
  • Caller must be market creator or contract owner
  • Market must be in Open status
Emits: MarketCancelled event

View Functions

getMarket

Get complete market details.
function getMarket(uint256 marketId)
    external
    view
    returns (Market memory market);
Returns: Complete market data structure with all fields

marketCreationFee

Get the current market creation fee.
function marketCreationFee() external view returns (uint256);
Returns: Fee amount in wei (BNB)

resolver

Get the current authorized resolver address.
function resolver() external view returns (address);

marketCounter

Get the total number of markets created.
function marketCounter() external view returns (uint256);

getContractBalance

Get the contract BNB balance.
function getContractBalance() external view returns (uint256);

Admin Functions

These functions are restricted to the contract owner.

setMarketCreationFee

Update the market creation fee.
function setMarketCreationFee(uint256 newFee) external;
Emits: FeeUpdated event

setResolver

Update the authorized resolver address.
function setResolver(address newResolver) external;
Emits: ResolverUpdated event

withdrawFees

Withdraw accumulated creation fees.
function withdrawFees(address payable to, uint256 amount) external;
Emits: FeesWithdrawn event

recoverERC20

Recover ERC20 tokens sent to contract by mistake.
function recoverERC20(address token, address to, uint256 amount) external;
Emits: TokensRecovered event

Market States

DelphAI markets have 3 possible states:
enum MarketStatus {
    Open,
    Resolved,
    Cancelled
}

Next Steps

I