Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.unitedmarket.ai/llms.txt

Use this file to discover all available pages before exploring further.

Orders are submitted through the backend as EIP-712 signed payloads. Backend authentication and order signing are separate: a wallet session can identify a user, but the order itself must still be signed. For the full SIWE login flow before placing or cancelling orders, see Sign In & Trade.
NetworkBase URL
Mainnethttps://backend.themarketunited.com
Testnethttps://backend-develop.themarketunited.com
United Market is currently in sandbox/development stage. All funds, balances, markets, and trades are for testing only and do not represent real money.

1. Load Market Data

Fetch the market first so your client knows the market id, condition id, and outcome token ids.
curl "https://backend.themarketunited.com/markets/{id}/trading"

2. Approve Trading Contracts

Before trading, the wallet must approve the exchange contract.
ActionApproval
Buy outcome tokensApprove the collateral ERC-20 for CTFExchange.
Sell outcome tokensCall setApprovalForAll(CTFExchange, true) on the ConditionalTokens contract.
Use the exchange address for the network you are trading on. See Contracts for mainnet and testnet addresses.

3. Build the EIP-712 Domain

const domain = {
  name: "Polymarket CTF Exchange",
  version: "1",
  chainId,
  verifyingContract: exchangeAddress,
} as const;

4. Sign the Order

const types = {
  Order: [
    { name: "salt", type: "uint256" },
    { name: "maker", type: "address" },
    { name: "signer", type: "address" },
    { name: "taker", type: "address" },
    { name: "tokenId", type: "uint256" },
    { name: "makerAmount", type: "uint256" },
    { name: "takerAmount", type: "uint256" },
    { name: "expiration", type: "uint256" },
    { name: "nonce", type: "uint256" },
    { name: "feeRateBps", type: "uint256" },
    { name: "side", type: "uint8" },
    { name: "signatureType", type: "uint8" },
  ],
} as const;

const order = {
  salt: BigInt(Date.now()),
  maker: walletAddress,
  signer: walletAddress,
  taker: "0x0000000000000000000000000000000000000000",
  tokenId,
  makerAmount,
  takerAmount,
  expiration: 0n,
  nonce: 0n,
  feeRateBps: 0n,
  side: 0,
  signatureType: 0,
};

const signature = await walletClient.signTypedData({
  account: walletAddress,
  domain,
  types,
  primaryType: "Order",
  message: order,
});

5. Submit the Order

curl -X POST "https://backend.themarketunited.com/markets/{id}/orders" \
  -H "Content-Type: application/json" \
  -d '{
    "orderType": "GTC",
    "order": {
      "salt": "123456789",
      "maker": "0xYourWallet",
      "signer": "0xYourWallet",
      "taker": "0x0000000000000000000000000000000000000000",
      "tokenId": "9173991505859985195806122260131852520306883753774963004628888314748377483211",
      "makerAmount": "50000000",
      "takerAmount": "100000000",
      "expiration": "0",
      "nonce": "0",
      "feeRateBps": "0",
      "side": 0,
      "signatureType": 0,
      "signature": "0x..."
    }
  }'
The response includes an orderHash. Store it for order status and cancellation.

Order Types

TypeBehavior
GTCGood-till-cancelled. The order rests until filled, cancelled, or expired.
IOCImmediate-or-cancel. Fills what it can immediately and cancels the rest.
FOKFill-or-kill. Must fully fill immediately or the order is rejected.
POST_ONLYMaker-only. Rejected if it would immediately cross the spread.
MARKETTakes the best available liquidity. Unfilled remainder is cancelled.

Amount Conventions

SidemakerAmounttakerAmount
BUYCollateral amountOutcome token amount
SELLOutcome token amountCollateral amount

Check or Cancel the Order

curl "https://backend.themarketunited.com/orders/0xORDER_HASH"
curl -X POST "https://backend.themarketunited.com/markets/{id}/orders/cancel" \
  -H "Content-Type: application/json" \
  -d '{ "orderHash": "0xORDER_HASH" }'