π Market Creation for Developers & AI Integration
Developers and AI agents can automate market creation by interacting directly with the BigMarket smart contract. This section covers how to structure the request, sign data, and interact with the create-market function.
π οΈ Smart Contract Function: create-market
To create binary and categorical markets via smart contract, call:To create binary and categorical markets via smart contract, call:
Note: Categories for scalar markets are list of min/max points and these must be contiguous.
π Required Parameters
Parameter
Type
Description
categories
list 10 (string-ascii 64) or list 10 ({min:uint, max:uint})
Market outcomes (e.g. yes/no for binary)
fee-bips
optional uint
Market fee in basis points (100 bips = 1%)
token
ft-token
Fungible token used (must be DAO-approved)
market-data-hash
buff 32
Hash of signed market data
proof
list 10 (tuple (position bool) (hash (buff 32)))
Merkle proof (if gating is enabled)
treasury
principal
Address where market fees are sent
π Off-Chain Data Signing
To ensure data integrity, market data must be signed before submission. This prevents malicious modifications. The hash is then passed to the create-market function.
π Example API Integration (TypeScript)
Hereβs an example of how to create a market using an API request:
CreateMarketRequest {
name: string;
type: "binary" | "categorical" | "scalar";
description: string;
criteria: string;
treasury: string;
marketImage: string;
feePercentage: number;
token: string;
categories: string[];
socialLinks: {
twitter?: string;
discord?: string;
website?: string;
};
}
// Example usage
const newMarket = {
name: "Will Bitcoin reach $100K in 2025?",
type: "binary",
description: "Predict if Bitcoin will cross $100,000 before the end of 2025.",
criteria: "Resolution based on Bitcoin price on December 31, 2025.",
treasury: "SP123456789...",
marketImage: "https://example.com/market-image.png",
feePercentage: 200,
token: "STX",
category: 'crypto',
categories: ["Yes", "No"], // binary market
social: { twitter: {projectHandle: 'Stacks'}, discord: {serverId: '1306302974515089510'}, website: {url: 'https://www.stacks.co/'}}
};
const newMarket = {
name: "Best film in Baftas",
type: "binary",
description: "Which films will win best overall?",
criteria: "Baesed on official announcement",
treasury: "SP123456789...",
marketImage: "https://example.com/market-image.png",
feePercentage: 200,
token: "STX",
category: 'politics',
categories: ["Film 1", "Film 2", "Film 3"], // categorical market
social: { twitter: {projectHandle: 'Stacks'}, discord: {serverId: '1306302974515089510'}, website: {url: 'https://www.stacks.co/'}}
};