Sync

Order Sync (alias of Transaction Sync)

Deprecated alias of POST /api/v1/sync, kept for old clients: same validation, same decoder, same rate limit (60 req/min per IP) and same response, plus a message field. Call /api/v1/sync instead. Note that buyOrder now takes a maxCost: buyOrder(market, orderId, fill, maxCost).

POST
/api/v1/orders/sync
Alias of POST /api/v1/sync (deprecated). Indexes every BASIS event of the transaction, order events included.
Auth: None

Request Body (JSON)

Response
{
  "txHash": "0x..."
}

marketType is still accepted and ignored: the market host is taken from each log's emitter.

What it does

  1. Fetches the transaction receipt from the chain and decodes every BASIS log of the transaction
  2. Takes the market host (public or private) from each log's emitter
  3. Folds the order from OrderCreated, OrderFilled and OrderCancelled, with no contract read

Response

Response
{
  "success": true,
  "status": "synced",
  "chainId": 4663,
  "txHash": "0x...",
  "blockNumber": 41234567,
  "confirmed": false,
  "events": [
    { "type": "OrderCreated", "contractAddress": "0x...", "logIndex": 3, "inserted": true }
  ],
  "inserted": 1,
  "typed": { "MarketEvent": 1 },
  "loan": null,
  "updown": { "success": true, "events": 0 },
  "message": "Order synced from transaction."
}
200 Synced400 Missing or invalid txHash422 Not mined yet, reverted, or the write failed429 Rate limit exceeded
Example Code
// After creating a sell order on-chain, sync it to the database
const tx = await walletClient.writeContract({
  address: HOST_ADDRESS, // the market's own host: marketTrading (public) or privateMarket (private) in /contracts.json
  abi: PREDICTION_ABI,
  functionName: "listOrder",
  // pricePerShare: odds x 1e18, from 0.001 (1e15) to 0.999 (999e15), or 0 to sell at the live AMM price
  args: [marketToken, outcomeId, amount, pricePerShare],
});

// Wait for confirmation
await publicClient.waitForTransactionReceipt({ hash: tx });

// Sync to database (works with session cookie or API key)
// /api/v1/orders/sync is an alias of /api/v1/sync; marketType is ignored
const syncRes = await fetch("https://launchonbasis.com/api/v1/sync", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "X-API-Key": "bsk_your_key",
  },
  body: JSON.stringify({ txHash: tx }),
});
const { success } = await syncRes.json();