Open app

API reference

Markdown

Answer a swap’s bonus flip

PUT/v2/swaps/{id}/coinflip

Submit a coinflip decision for an eligible order.

Authentication: Required: the order’s owner session in X-Session-ID.

#Parameters

Name In Type Required Description
id path string (pattern ^[A-Za-z0-9:_-]{1,128}$) Yes Public order identifier. Not a credential: every read still requires the owner session or the destination proof.

#Request body

  • round · integer · required — The pending round this decision answers. A stale decision is rejected, never applied to a later round.
  • accept · boolean · required — Whether to take the offered flip. false cashes the bonus out instead. Omission is never treated as a decline — the field is required.
  • clientSeed · string (max 64, pattern ^[\x20-\x7E]*$) or null — Your half of the provably-fair seed. The outcome is HMAC(serverSeed, clientSeed), and SHA256(serverSeed) is committed before you choose it. Omit to let the engine use a fallback seed.
  • side · "cow" · "milk" or null — Which band wins. It selects the winning range only and never feeds the HMAC, so it cannot change the drawn number.
  • stakeAtomic · string (atomic integer) or null — Coinflip TABLE only: the bet for this round, in the asset's smallest unit. Proposed, not binding — the engine refuses a bet above your balance, below the minimum, or beyond the pool's exposure cap, and leaves the round open so you can correct it. Ignored by the in-swap bonus, which always stakes the whole delivery.

#Response

200 returns an object with:

  • round · number
  • result · number
  • won · boolean
  • side · "cow" · "milk"
  • multiplier · number
  • finalMultiplier · number or null · required
  • serverSeed · string
  • seedHash · string
  • cashedOut · boolean
  • revealedUnusedSeed · string
  • unusedSeedHash · string
  • nextRound · object or null
    • round · number · required
    • seedHash · string · required
    • multiplierIfWin · number · required
    • currentMultiplier · number · required
    • decisionDeadline · string
  • policy · object
    • edgePercent · number · required
    • milkWinBelow · number · required
    • cowWinAbove · number · required
    • winChancePercent · number · required
    • maxWalletFractionPercent · number
    • maxPayoutAtomic · string (atomic integer) — Positive base-10 integer in the asset’s atomic unit.

Errors use the standard error envelope: branch on code, never on the message.

#Example

curl
curl -X PUT 'https://api-beta.wagyu.xyz/v2/swaps/<orderId>/coinflip' \
  -H 'x-session-id: <sessionId>' \
  -H 'content-type: application/json' \
  -d '{
    "round": 1,
    "accept": false
  }'
JavaScript
const res = await fetch('https://api-beta.wagyu.xyz/v2/swaps/<orderId>/coinflip', {
  method: 'PUT',
  headers: {"content-type":"application/json","x-session-id":"<sessionId>"},
  body: JSON.stringify({
    "round": 1,
    "accept": false
  }),
});
const data = await res.json();
Python
import requests

res = requests.put('https://api-beta.wagyu.xyz/v2/swaps/<orderId>/coinflip', headers={"x-session-id":"<sessionId>"}, json={
        "round": 1,
        "accept": False
    }, timeout=30)
data = res.json()

No response is captured for this route: calling it creates or changes a real order. The response fields above come from the live contract.

Tip: every page is also plain Markdown, and /llms.txt indexes them for AI tools.