> ## 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.

# Sign In & Trade

> Sign in with SIWE, then place or cancel orders through the backend API.

Use Sign-In with Ethereum (SIWE) when calling user-specific endpoints such as authenticated order management, comments, profile updates, or private account views.

Order signing is separate from SIWE. SIWE proves the user owns a wallet session for backend auth; EIP-712 order signing proves the user authorized a specific trade.

| Base URL                      | Chain ID |
| ----------------------------- | -------- |
| `https://api.unitedmarket.ai` | `56`     |

<Note>
  United Market is now live on BNB Smart Chain mainnet. We just launched — start trading on-chain prediction markets today.
</Note>

## 1. Request a SIWE Nonce

```bash theme={null}
curl "https://api.unitedmarket.ai/auth/nonce/0xYourWallet"
```

Response:

```json theme={null}
{
  "nonce": "abc123"
}
```

## 2. Create and Sign the SIWE Message

```ts theme={null}
import { SiweMessage } from "siwe";

const backendUrl = "https://api.unitedmarket.ai";
const chainId = 56;

const siwe = new SiweMessage({
  domain: new URL(backendUrl).hostname,
  address: walletAddress,
  statement: "Sign in to trade.",
  uri: backendUrl,
  version: "1",
  chainId,
  nonce,
});

const message = siwe.prepareMessage();

const signature = await walletClient.signMessage({
  account: walletAddress,
  message,
});
```

## 3. Verify the Signature

```bash theme={null}
curl -X POST "https://api.unitedmarket.ai/auth/verify" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "SIWE_MESSAGE",
    "signature": "0xSIGNATURE"
  }'
```

Response:

```json theme={null}
{
  "accessToken": "jwt...",
  "refreshToken": "jwt...",
  "user": {
    "id": "0xYourWallet"
  }
}
```

Store the `accessToken` for authenticated requests. Store the `refreshToken` if your client supports refreshing sessions.

## 4. Use the Bearer Token

```bash theme={null}
curl "https://api.unitedmarket.ai/me/orders" \
  -H "Authorization: Bearer ACCESS_TOKEN"
```

## 5. Place an Order After Sign-in

Signing in does not replace order signing. Build and sign the EIP-712 order using the mainnet exchange address.

```ts theme={null}
const domain = {
  name: "Polymarket CTF Exchange",
  version: "1",
  chainId: 56,
  verifyingContract: "0x8db26793D99b2E9Ac53102de110Fe783F676D516",
} as const;

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

Then submit the signed order. Include the bearer token when your integration is using authenticated order routes or user-specific order management. Sign the market's effective fee from `GET /markets/{id}/fee` into `feeRateBps` — see [Place an Order](/guides/place-order).

```bash theme={null}
curl -X POST "https://api.unitedmarket.ai/markets/{id}/orders" \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "orderType": "GTC",
    "order": {
      "salt": "123456789",
      "maker": "0xYourWallet",
      "signer": "0xYourWallet",
      "taker": "0x0000000000000000000000000000000000000000",
      "tokenId": "TOKEN_ID",
      "makerAmount": "50000000",
      "takerAmount": "100000000",
      "expiration": "0",
      "nonce": "0",
      "feeRateBps": "15",
      "side": 0,
      "signatureType": 0,
      "signature": "0x..."
    }
  }'
```

## 6. Cancel an Order

Cancel by market and order hash:

```bash theme={null}
curl -X POST "https://api.unitedmarket.ai/markets/{id}/orders/cancel" \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "orderHash": "0xORDER_HASH" }'
```

Some authenticated routes may also support cancelling directly by order hash:

```bash theme={null}
curl -X POST "https://api.unitedmarket.ai/orders/0xORDER_HASH/cancel" \
  -H "Authorization: Bearer ACCESS_TOKEN"
```

## 7. Refresh a Session

```bash theme={null}
curl -X POST "https://api.unitedmarket.ai/auth/refresh" \
  -H "Content-Type: application/json" \
  -d '{ "refreshToken": "REFRESH_TOKEN" }'
```

Use the returned `accessToken` for future authenticated requests.
