Documentation Index Fetch the complete documentation index at: https://docs.delphai.io/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before you begin, make sure you have:
Smart Contract Knowledge Basic understanding of Solidity and smart contracts
Prediction Market Platform A prediction market dApp that needs resolution
Quick Integration
Connect to delphAI Contract
Import the delphAI interface and connect to the oracle. // SPDX-License-Identifier: MIT
pragma solidity ^0.8.20 ;
interface IDelphAI {
function createMarket (
string memory question ,
string memory description ,
string [] memory possibleOutcomes ,
uint256 resolutionTimestamp
) external payable returns ( uint256 );
function getMarket ( uint256 marketId ) external view returns ( Market memory );
function marketCreationFee () external view returns ( uint256 );
}
contract YourMarket {
IDelphAI public immutable delphAI;
constructor ( address _delphAI ) {
delphAI = IDelphAI (_delphAI);
}
}
Create a Market
Create markets with AI resolution by paying the creation fee. function createYesNoMarket (
string memory question ,
string memory description ,
uint256 resolutionTime
) external payable returns ( uint256 ) {
string [] memory outcomes = new string []( 2 );
outcomes[ 0 ] = "Yes" ;
outcomes[ 1 ] = "No" ;
return delphAI.createMarket{value : msg .value}(
question,
description,
outcomes,
resolutionTime
);
}
Query Market Resolution
Check market status and get the AI resolution. function getWinningOutcome ( uint256 marketId )
external
view
returns ( string memory )
{
Market memory market = delphAI. getMarket (marketId);
require (market.status == MarketStatus.Resolved, "Not resolved yet" );
return market.possibleOutcomes[market.outcomeIndex];
}
function getAIResolution ( uint256 marketId )
external
view
returns (
string memory explanation ,
string [] memory sources ,
uint8 confidence
)
{
Market memory market = delphAI. getMarket (marketId);
return (
market.resolutionData,
market.resolutionSources,
market.resolutionConfidence
);
}
Test Your Integration
Test with a sample market on testnet. // Using ethers.js
const creationFee = await delphAI . marketCreationFee ();
const tx = await yourMarket . createYesNoMarket (
"Will BTC reach $100k by Dec 31, 2025?" ,
"Resolves YES if Bitcoin >= $100,000 on any major exchange" ,
1735689600 , // Unix timestamp
{ value: creationFee }
);
await tx . wait ();
console . log ( 'Market created and awaiting AI resolution!' );
Example: Full Market Integration
Here’s a complete example of integrating delphAI into your prediction market:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20 ;
interface IDelphAI {
function createMarket (
string memory question ,
string memory description ,
string [] memory possibleOutcomes ,
uint256 resolutionTimestamp
) external payable returns ( uint256 );
function getMarket ( uint256 marketId ) external view returns ( Market memory );
function marketCreationFee () external view returns ( uint256 );
}
struct Market {
uint256 id;
address creator;
string question;
string description;
string [] possibleOutcomes;
uint256 createdAt;
uint256 resolutionTimestamp;
MarketStatus status;
uint256 outcomeIndex;
string resolutionData;
string [] resolutionSources;
uint8 resolutionConfidence;
bytes proofData;
uint256 resolvedAt;
address resolvedBy;
}
enum MarketStatus { Open , Resolved , Cancelled }
contract PredictionMarket {
IDelphAI public immutable delphAI;
struct MarketData {
uint256 delphAIMarketId;
mapping ( address => mapping ( uint256 => uint256 )) bets;
uint256 totalPool;
}
mapping ( uint256 => MarketData) public markets;
constructor ( address _delphAI ) {
delphAI = IDelphAI (_delphAI);
}
function createMarket (
string memory question ,
string memory description ,
string [] memory outcomes ,
uint256 resolutionTime
) external payable returns ( uint256 ) {
// Get creation fee and create market on delphAI
uint256 marketId = delphAI.createMarket{value : msg .value}(
question,
description,
outcomes,
resolutionTime
);
// Store market ID for later
markets[marketId].delphAIMarketId = marketId;
return marketId;
}
function placeBet ( uint256 marketId , uint256 outcome )
external
payable
{
Market memory market = delphAI. getMarket (marketId);
require (market.status == MarketStatus.Open, "Market not open" );
require ( block .timestamp < market.resolutionTimestamp, "Market closed" );
markets[marketId].bets[ msg.sender ][outcome] += msg .value;
markets[marketId].totalPool += msg .value;
}
function claimWinnings ( uint256 marketId ) external {
Market memory market = delphAI. getMarket (marketId);
require (market.status == MarketStatus.Resolved, "Not resolved" );
uint256 winningOutcome = market.outcomeIndex;
uint256 userBet = markets[marketId].bets[ msg.sender ][winningOutcome];
require (userBet > 0 , "No winning bet" );
// Your payout logic here
// Calculate and transfer winnings
markets[marketId].bets[ msg.sender ][winningOutcome] = 0 ;
}
function getWinningOutcome ( uint256 marketId )
external
view
returns ( string memory )
{
Market memory market = delphAI. getMarket (marketId);
require (market.status == MarketStatus.Resolved, "Not resolved" );
return market.possibleOutcomes[market.outcomeIndex];
}
}
Integration Checklist
Smart Contract Setup
Import delphAI interface
Deploy your market contract
Connect to delphAI oracle address
Test on testnet
Market Creation
Define clear, verifiable questions
Set appropriate resolution times
Specify possible outcomes
Pay creation fee in BNB
Query Resolution
Poll market status regularly
Retrieve winning outcome when resolved
Get AI explanation and reasoning
Handle different market states (Open/Resolved/Cancelled)
Testing & Security
Test full market lifecycle
Audit your contract integration
Handle edge cases
Monitor gas costs
Network Addresses
Network Oracle Address Chain ID BSC Mainnet 0xA95E99848a318e37F128aB841b0CF693c1f0b4D156
Next Steps
Core Concepts Understand how delphAI resolves markets
Resolution Criteria Learn how to write effective criteria
Smart Contract API Explore the full contract interface
Best Practices Follow integration best practices
Need Help?
Developer Support Join our Discord for developer support and integration help