Add markets to your game, app, or fan economy.
Moxie is a programmable exchange API for contract markets: in-game item markets, prediction games, parimutuel pools, HKJC-style racing products, royalty-linked assets, and cross-market portfolios. You create a market, quote a trade, submit the order, and subscribe to settlement. Moxie handles clearing, compliance preflight, receipts, and realtime updates behind the SDK.
Start with products, not protocol jargon
A contract market is any market where the payout depends on terms, events, ownership, or time. Moxie gives you one exchange surface for those markets, then clears related exposure together instead of forcing every app to build a one-off trading backend.
Game developers
Create a market for a skin, card, trophy, pack, or tournament item. Players can buy, sell, or quote the item from your backend while your game keeps the native UX. The same account can later hold prediction positions, item inventory, and rewards without a separate clearing system per feature.
import { Client, GridSizeCode, GeneratorCode } from "@moxie/sdk";
const moxie = new Client({ apiKey: process.env.MOXIE_API_KEY });
// Open price discovery for a limited in-game item.
await moxie.createContinuousMarket({
key: process.env.MOXIE_SIGNING_KEY,
market_id: "0x<64-hex-dragon-skin-market>",
omega_lo: "0",
omega_hi: "100000000000000000000", // 0..100 units
grid_size_code: GridSizeCode.N64,
generator_code: GeneratorCode.Entropy,
initial_mu: ["25000000000000000000"], // starts around 25
swap_fee_bps: 30,
});
Sports, racing, and live events
Build prediction markets, round-by-round fight games, racing pools, and parimutuel products where many outcomes clear together. A Hong Kong Jockey Club style pool, a combat-sports card, and a tournament bracket all reduce to event-linked markets with settlement receipts.
// One market, multiple outcomes, settled when the event resolves.
await moxie.createStandaloneMarket({
key: process.env.MOXIE_SIGNING_KEY,
market_id: "0x<64-hex-race-market>",
question: "Which horse wins Race 7?",
resolution_time: 1780000000,
outcome_count: 14,
collateral_token: "USDC",
});
await moxie.predictionMint({
key: process.env.MOXIE_SIGNING_KEY,
prediction_id: "0x<64-hex-ticket>",
event_id: "0x<64-hex-race-event>",
outcome_index: 6,
amount: "50000000000000000000",
});
Brands, IP, and commerce
Attach markets to merch, drops, royalties, access passes, media catalogs, or cross-brand collaborations. Moxie exposes normal SDK calls for commerce and trading, while the deeper settlement layer keeps receipts, payout paths, and compliance evidence tied to the market.
const merch = await moxie.getMerchandise("0x<brand-id>");
const order = await moxie.merchOrder({
buyer: "0x<player-wallet>",
itemId: merch[0].id,
brandId: "0x<brand-id>",
quantity: 1,
paymentToken: "USDC",
maxPrice: "50000000000000000000",
});
console.log(order.order_id, order.status);
Install an SDK and create your first market
Start with the product action: create a market, ask Moxie for a quote, submit the trade, then wait for a receipt. Under the hood, the market can be continuous, event-driven, parimutuel, spot, or hybrid. The details are available below; the first integration is just a few SDK calls.
TypeScript — @moxie/sdk
Best first path for a web app, game backend, or commerce service. The TypeScript client exposes named methods, typed errors, idempotency headers, receipt polling, compliance preflight helpers, and realtime block subscriptions. The integer constants in the example are stable wire values; most builders only touch them when creating custom market shapes.
$ npm install @moxie/sdk@rc # v1.0.0-rc.1
import {
Client,
GridSizeCode,
GeneratorCode,
DirectionCode,
} from "@moxie/sdk";
const moxie = new Client({
baseUrl: "http://localhost:8545",
apiKey: process.env.MOXIE_API_KEY,
});
// Create a market for a limited in-game item.
const txHash = await moxie.createContinuousMarket({
key: "0x<64-hex>",
market_id: "0x<64-hex-dragon-skin-market>",
omega_lo: "0",
omega_hi: "100000000000000000000",
grid_size_code: GridSizeCode.N64,
generator_code: GeneratorCode.Entropy,
initial_mu: ["25000000000000000000"],
swap_fee_bps: 30,
});
// Quote a player buying exposure to the 20..30 price band.
const quote = await moxie.quoteContinuous({
market_id: "0x<64-hex-dragon-skin-market>",
omega_a: "20000000000000000000",
omega_b: "30000000000000000000",
delta_amount: "1000000000000000000",
direction_code: DirectionCode.Buy,
});
console.log(quote.total_payout, quote.iterations_used);
// Submit the trade; the SDK waits for the receipt by default.
const swap = await moxie.swapContinuous({
key: "0x<64-hex>",
market_id: "0x<64-hex-dragon-skin-market>",
omega_a: "20000000000000000000",
omega_b: "30000000000000000000",
delta_amount: "1000000000000000000",
direction_code: DirectionCode.Buy,
});
console.log(swap);
Rust — moxie-sdk
Use Rust for validators, market-making bots, settlement workers, data pipelines, and services that need tight control over signing and replay. Create a MoxieClient with MoxieClient::builder(); typed resource namespaces cover the stable high-level domains, while client.raw() exposes every registered RPC method.
[dependencies]
moxie-sdk = "1.0.0-rc.1"
serde_json = "1"
tokio = { version = "1", features = ["full"] }
use moxie_sdk::MoxieClient;
use serde_json::json;
let client = MoxieClient::builder()
.base_url("http://localhost:8545")
.build()?;
let params = json!({
"key": "0x<64-hex>",
"market_id": "0x<64-hex>",
"omega_lo": "0",
"omega_hi": "1000000000000000000",
"grid_size_code": 3, // N64
"generator_code": 1, // Entropy
"initial_mu": ["500000000000000000"],
"swap_fee_bps": 30,
});
let tx = client
.raw()
.create_continuous_market(&[params])
.await?;
Python — moxie-sdk
Use Python for notebooks, analytics, pricing experiments, reporting, and operations scripts. The package installs as moxie-sdk and imports as moxie_sdk. Typed resources cover the common product surfaces; client.rpc() remains the exact JSON-RPC escape hatch.
$ pip install moxie-sdk==1.0.0rc1
from moxie_sdk import MoxieClient
moxie = MoxieClient(base_url="http://localhost:8545")
tx = moxie.rpc("moxie_createContinuousMarket", {
"key": "0x<64-hex>",
"market_id": "0x<64-hex>",
"omega_lo": "0",
"omega_hi": "1000000000000000000",
"grid_size_code": 3, # N64
"generator_code": 1, # Entropy
"initial_mu": ["500000000000000000"],
"swap_fee_bps": 30,
})
quote = moxie.rpc("moxie_quoteContinuous", {
"market_id": "0x<64-hex>",
"omega_a": "100000000000000000",
"omega_b": "200000000000000000",
"delta_amount": "10000000000000000000",
"direction_code": 0, # Buy
})
print(quote["total_payout"], quote["iterations_used"])
One exchange surface, many builder environments
Use the hand-maintained SDKs when you want the fastest path to production. Use generated SDKs when your team standardizes on enterprise languages. Use game-engine wrappers when Moxie should feel like a native game service instead of an external finance API.
Tier 1 — TypeScript, Rust, Python
Start here for most applications. TypeScript fits web apps, Roblox/OpenCloud-adjacent backends, creator tools, and dashboards. Rust fits market makers, validators, and settlement workers. Python fits notebooks, analytics, pricing, and ops scripts. All three expose the same market families: brands, merch, tickets, drops, predictions, continuous markets, racing, chain reads, receipts, and raw RPC escape hatches.
$ npm install @moxie/sdk@rc # v1.0.0-rc.1
$ cargo add moxie-sdk@"1.0.0-rc.1" # v1.0.0-rc.1
$ pip install moxie-sdk==1.0.0rc1 httpx # v1.0.0rc1
Tier 2 — Go, Java, C#, Kotlin, Swift
Use generated clients when Moxie is part of a larger enterprise or studio backend. The generated layer keeps request and response shapes exact; thin handwritten wrappers add retry, pagination, receipt polling, and amount helpers so teams do not have to hand-roll transport behavior.
$ go get github.com/momentum-sez/moxie-sdk-go
$ mvn dependency:get -Dartifact=inc.momentum:moxie-sdk-java:0.1.0
$ dotnet add package Moxie.Sdk
$ implementation "inc.momentum:moxie-sdk-kotlin:0.1.0" # Gradle
$ .package(url: "https://github.com/momentum-sez/moxie-sdk-swift") # SwiftPM
Tier 3 — game-engine wrappers
Unity, Unreal, Godot, and Roblox integrations wrap the Rust SDK core so games can create markets, quote trades, subscribe to settlement, and show inventory state without exposing signing keys inside client code. Unity uses P/Invoke + UPM; Unreal uses a C++ plugin; Godot uses GDExtension; Roblox uses HttpService with signing in a backend service.
# Unity (UPM)
$ openupm add inc.momentum.moxie-sdk
# Unreal (C++ plugin)
$ git submodule add \
https://github.com/momentum-sez/moxie-sdk-unreal \
Plugins/MoxieSdk
# Godot (GDExtension)
# Roblox (OpenCloud backend)
Need the exact wire surface?
Open the full Moxie API spec when you are wiring production paths: auth profiles, agent invocation envelopes, settlement jobs, continuous-market parameters, JSON-RPC methods, receipt proofs, realtime streams, and amount utilities.
Reference for backend, engine, and market infrastructure teams
The builder page stays focused on what you can ship first. The spec page carries the dense protocol material: clearing primitives, compliance preflight, AOT settlement receipts, MCP agent tools, method families, pagination, errors, WebSockets, and SDK amount helpers.
Open the Moxie API spec// Move from first-market integration to exact wire semantics.
await moxie.preflightCompliance({ purpose, entity_ids });
await moxie.submitSigned(signedEnvelope, { preflight });
await moxie.getReceipt(txHash, { includeProof: true });
await moxie.subscribeBlocks(({ height }) => sync(height));