Integrator docs · REST · Events · ICP
Build on Betable
Trading apps, bots, and integrations — REST reads, signed auth, webhooks/SSE, and native canister writes on the CLOB.
Architecture
Betable is a prediction market on the Internet Computer with a Polymarket-style CLOB. Trades run on internal balances — zero ledger calls on the hot path.
Zero-latency trades
Place / cancel / match never touch the ICP ledger. Only deposit & withdraw do.
Multi-agent keys
Link many dfx / aigent principals in Wallet. Each debit your funded trading account.
REST + events
Public reads, webhooks & SSE for realtime. Direct canister calls for writes.
Funds model
Who pays depends on who calls — Betable does not auto-fund dfx identities.
Users & linked agents
Human II funds balances[II]. Link any number of agent / dfx principals in Wallet → Linked agents. Agent calls resolve to the user’s trading account.
Afta bags / DAB vaults
Bag is the trader. Fund via #BetableFundTrading, place via #BetablePlaceOrder. Claims mirror agents: #BetableClaimWinnings (= claim_winnings, incl. one-sided peri #draw) and #BetableClaimRefund (= void only). order.user = bag — not the human II.
How integration works
Fund the user trading account
User deposits ICP / MICP on Wallet. Hot-path trades spend balances[II] — no ledger approve per order.
Link agent principal(s)
In Wallet → Linked agents, paste each dfx / aigent principal (many allowed). Or generate an Ed25519 key and register it. On-chain: register_trading_key.
Trade as the agent
Agent signs place_order_v2 / place_crypto_bet as itself. resolve_balance_owner maps to the user’s funded account.
Subscribe to events
Webhooks for push or SSE for realtime fills, order updates, and market lifecycle. REST for public reads.
Key concepts
Polymarket-style CLOB
Complementary match when price_a + price_b >= 1.0 ICP (100e6 e8s). Price-time priority; partial fills; multi-outcome complements allowed.
Internal balance model
Per principal: { available, reserved } per game mode. Place → reserved; fill → position; cancel → available. Only deposit/withdraw hit the ledger.
Idempotent orders
place_order_v2 with client_order_id. Duplicate IDs return the original order.