Comprehensive API documentation with function signatures, parameters, and examples
[Deployed Address][Token Address][Token Address]event EventCreated( bytes32 indexed eventId, string description, uint256 startTime, uint256 endTime );
Emitted when a new betting event is created.
event BetPlaced( bytes32 indexed betId, address indexed bettor, bytes32 indexed eventId, uint256 amount, LibBetting.BetType betType );
Emitted when a bet is successfully placed.
function createEvent( bytes32 eventId, string memory description, uint256 startTime, uint256 endTime ) external onlyAdmin
Description: Creates a new betting event.
Parameters:
eventId: Unique identifier for the eventdescription: Human-readable event descriptionstartTime: Unix timestamp when betting startsendTime: Unix timestamp when betting endsAccess: Admin only
Emits: EventCreated
function placeBet( bytes32 eventId, LibBetting.BetType betType, uint256 minOdds ) external payable
Description: Places a bet on an active event.
Parameters:
eventId: Event to bet onbetType: For (1) or Against (0)minOdds: Minimum acceptable odds (slippage protection)Payment: Requires ETH payment (bet amount)
Returns: Creates bet with unique betId
Emits: BetPlaced
function createMarket( bytes32 eventId, uint256 initialOddsFor, uint256 initialOddsAgainst ) external payable onlyMarketMaker
Description: Creates a new market with initial liquidity.
Access: Market Maker only
Payment: Requires ETH payment (initial liquidity)
Emits: MarketCreated
function getMarketPrices(bytes32 eventId) external view returns (uint256 oddsFor, uint256 oddsAgainst)
Description: Gets current market prices.
Returns:
oddsFor: Current odds for "For" sideoddsAgainst: Current odds for "Against" side// Connect to Diamond contract
const diamond = new ethers.Contract(diamondAddress, diamondABI, signer);
// Create a new event (admin only)
const eventId = ethers.utils.formatBytes32String("MATCH_001");
const description = "Arsenal vs Chelsea";
const startTime = Math.floor(Date.now() / 1000) + 3600; // 1 hour from now
const endTime = startTime + 7200; // 2 hours duration
await diamond.createEvent(eventId, description, startTime, endTime);
// Place a bet
const betAmount = ethers.utils.parseEther("0.1"); // 0.1 ETH
const betType = 1; // For
const minOdds = 15000; // 1.5x minimum odds
await diamond.placeBet(eventId, betType, minOdds, { value: betAmount });# Connect to contract
contract = web3.eth.contract(address=diamond_address, abi=diamond_abi)
# Create event
event_id = Web3.solidityKeccak(['string'], ['MATCH_001'])
tx = contract.functions.createEvent(
event_id,
"Arsenal vs Chelsea",
int(time.time()) + 3600,
int(time.time()) + 7200
).transact()
# Place bet
bet_tx = contract.functions.placeBet(
event_id,
1, # For
15000 # Min odds
).transact({'value': Web3.toWei(0.1, 'ether')})