Skip to main content

Examples gallery

Real reference implementations you can read, fork, and ship. Every example lives in the OMY repo — these pages are the curated tour.

import {DocFeatures, DocFeature} from '@site/src/components/docs/DocFeatures';

Production examples

Market — binary prediction market

Status: ✅ Production-ready. Ships with the protocol.

The reference consumer of OMY. Implements: USDT split into YES + NO shares, constant-product AMM (buy YES / buy NO), oracle resolution via RequestResolution, redeem at $0.99/share, owner-bound treasury for the 1% silent skim, production-grade awaiting timeout escape.

Source: tolk/contracts/Market.tolk (~330 lines Tolk)
Storage: tolk/contracts/market-storage.tolk
Messages: tolk/contracts/market-messages.tolk
Factory: tolk/contracts/MarketFactory.tolk
Tests: tolk/tests/market*.test.tolk

What to study:

  • The constant-product math with ceil-rounding to protect LPs (Market.tolk:143-167)
  • The bond-vs-TVL clamp in RequestResolution
  • The anti-spoof on AssertionCreated (sender == factory)
  • The dedupe pattern on OracleResult (status guard + sender check)
  • The CancelAwaiting escape
  • The silent 1% skim at resolve time with dust-pool protection

Walk-through: Tutorial — build a market.

CommitteeResolver — Phase 1 multisig resolver

Status: ✅ Production-ready.

The Phase 1 resolver implementation. M-of-N multisig with case opening, voting, threshold checking, key rotation. The simplest possible "trusted arbitration" contract.

Source: tolk/contracts/CommitteeResolver.tolk
Tests: tolk/tests/committee_resolver.test.tolk

What to study:

  • How OpenVote from a disputed assertion creates a case
  • How votes are tallied and Resolve is sent back
  • Owner ops: AddSigner, RemoveSigner, SetThreshold

StakeVoteResolver — Phase 2 DVM

Status: ✅ Implemented and tested. Awaiting $OMY launch to activate.

The Phase 2 stake-weighted commit-reveal voting contract. Drop-in replacement for the committee — same OpenVote/Resolve interface, very different mechanism. Stakers escrow $OMY per commit; rewards/slashes are funded from the escrow (conserved, never insolvent).

Source: tolk/contracts/StakeVoteResolver.tolk (~600 lines Tolk)
Tests: tolk/tests/stake_vote_resolver.test.tolk

What to study:

  • The escrow refactor that closed C-1/C-2/C-3 + H-1
  • Commit-reveal flow with no-reveal slashing
  • The reopen + abandon path for cases that can't reach quorum
  • Claim-based reward distribution (no automatic sweeps)

Read the DVM page for the voter's perspective.

In-repo scenarios

Beyond the contracts, the repo includes scenario-*.tolk scripts that drive the full lifecycle end-to-end. These are the "reference deployment runbook":

ScriptDemonstrates
scenario-create.tolkSpawn an assertion via the factory + verify deploy address matches prediction
scenario-mint.tolkMint USDT to any wallet for bond posting
scenario-propose.tolkPost a bond + propose answer via TEP-74 transfer
scenario-finalize.tolkDrive the happy path: liveness window → finalize
scenario-dispute.tolkDrive the dispute path: post counter-bond from disputer
scenario-vote.tolkCommittee vote that drives Resolve
set-monetization.tolkOwner-only governance: set protocol fee + treasury

What's NOT yet open-sourced

The following reference implementations are on the roadmap but not yet shipped:

Mock bridge that uses OMY to attest cross-chain finality. Useful for teams building TON-to-EVM or TON-to-Cosmos bridges. Planned Phase B. Parametric insurance pool with policy NFTs, pooled premiums, and OMY-triggered payouts. Planned post-mainnet. Multi-milestone escrow for RWA settlement. Reference implementation of the document-signature + authority-registry patterns. Planned post-mainnet. TypeScript reference implementation of a finalize-on-timeout keeper + dispute-watcher. Currently exists in keeper/ at minimal viable quality; production-ready refactor planned.

Building a new consumer

The pattern is always the same — six handlers max:

match (msg) {
BindOracle => { /* set state.boundFactory, only at deploy */ }
RequestResolution => { /* send CreateAssertion to factory */ }
AssertionCreated => { /* verify sender == factory, bind assertion */ }
OracleResult => { /* verify sender == bound assertion, dedupe, act */ }
OracleDisputed => { /* optional — pause your business logic */ }
CancelAwaiting => { /* optional — escape from stuck Awaiting */ }
}

Plus your domain-specific logic (split / merge / trade / redeem / claim / whatever your contract does between request and resolution).

Read Tutorial for the full walkthrough using the Market as the worked example.

Contribute an example

If you build a consumer that's a good reference for a use case we haven't covered, open a PR. We'll review and link from this page.

The bar for getting linked:

  • MIT or Apache licensed
  • Tested (unit + integration)
  • Documented (README explains what + why)
  • Audit-considered (refund-and-return on bad inputs, dedupe, anti-spoof — see Security)

import {DocCards, DocCard} from '@site/src/components/docs/DocCards';