Skip to main content
POST
/
orders
/
cancel
/
v2
JavaScript
import { Wallet, hexlify, randomBytes } from "ethers";

const wallet = new Wallet(process.env.SX_PRIVATE_KEY);

const orderHashes = [
  "0x550128e997978495eeae503c13e2e30243d747e969c65e1a0b565c609e097506",
];
const salt = hexlify(randomBytes(32));
const timestamp = Math.floor(Date.now() / 1000);
const chainId = 4162; // Mainnet — use 79479957 for testnet

const domain = {
  name: "CancelOrderV2SportX",
  version: "1.0",
  chainId,
  salt,
};

const types = {
  Details: [
    { name: "orderHashes", type: "string[]" },
    { name: "timestamp", type: "uint256" },
  ],
};

const signature = await wallet.signTypedData(domain, types, { orderHashes, timestamp });

const result = await fetch("https://api.sx.bet/orders/cancel/v2", { // Mainnet — use https://api.toronto.sx.bet for testnet
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    orderHashes,
    signature,
    salt,
    maker: wallet.address,
    timestamp,
  }),
});
console.log(await result.json());
{
  "status": "success",
  "data": {
    "cancelledCount": 1,
    "orders": [
      {
        "orderHash": "0xc4fad4181eac3d72a7d4166df05534edd5479ec7053076244986ec68336ef45",
        "pendingFills": [
          {
            "fillHash": "0xf691c9dfb100d12550c3cb4dad944f15d711eaf22108c6dacc5077a274b3582l",
            "pendingFillAmount": "1806995918"
          }
        ]
      }
    ]
  }
}
Rate limit: All POST /orders/* endpoints share a combined limit of 5,500 requests/min. See Rate Limits.

Body

application/json
orderHashes
string[]
required

The order hashes to cancel

signature
string
required

Your wallet signature over the cancel payload. See the Order Signing reference for details on how to compute this.

salt
string
required

A random 32 bytes hex string to protect against replay

maker
string
required

The account from which you are cancelling orders

timestamp
integer
required

The current timestamp in UNIX seconds to protect against replay

Response

status
string

success or failure if the request succeeded or not

data
object