> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sx.bet/llms.txt
> Use this file to discover all available pages before exploring further.

# Order Signing

> How to sign order and fill payloads with your private key

Some API operations require a cryptographic signature from your wallet. The examples below show how to generate one using a private key or an injected browser wallet (e.g. MetaMask).

## Private key signing example

<CodeGroup>
  ```js JavaScript theme={null}
  import { Wallet } from "ethers";

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

  const domain = {
    name: "CancelOrderSportX",
    version: "1.0",
    chainId: 4162, // Mainnet — use 79479957 for testnet
  };

  const types = {
    Details: [
      { name: "message", type: "string" },
      { name: "orders", type: "string[]" },
    ],
  };

  const value = {
    message: "Are you sure you want to cancel these orders",
    orders: [
      "0x550128e997978495eeae503c13e2e30243d747e969c65e1a0b565c609e097506",
    ],
  };

  const signature = await wallet.signTypedData(domain, types, value);
  ```

  ```python Python theme={null}
  import os
  from eth_account import Account
  from eth_account.messages import encode_typed_data

  structured_data = {
      "types": {
          "EIP712Domain": [
              {"name": "name", "type": "string"},
              {"name": "version", "type": "string"},
              {"name": "chainId", "type": "uint256"},
          ],
          "Details": [
              {"name": "message", "type": "string"},
              {"name": "orders", "type": "string[]"},
          ],
      },
      "primaryType": "Details",
      "domain": {
          "name": "CancelOrderSportX",
          "version": "1.0",
          "chainId": 4162,  # Mainnet — use 79479957 for testnet
      },
      "message": {
          "message": "Are you sure you want to cancel these orders",
          "orders": [
              "0x550128e997978495eeae503c13e2e30243d747e969c65e1a0b565c609e097506",
          ],
      },
  }

  private_key = os.environ["PRIVATE_KEY"]
  signable_message = encode_typed_data(full_message=structured_data)
  signed = Account.sign_message(signable_message, private_key=private_key)
  signature = signed.signature.hex()
  ```
</CodeGroup>

Here we use a private key directly which is the most straightforward way to sign data and does not require access to an authenticated node. It's also the fastest.

***

## Injected provider signing example

```js theme={null}
import { BrowserProvider } from "ethers";

const provider = new BrowserProvider(window.ethereum);
const signer = await provider.getSigner();

const domain = {
  name: "CancelOrderSportX",
  version: "1.0",
  chainId: 4162, // Mainnet — use 79479957 for testnet
};

const types = {
  Details: [
    { name: "message", type: "string" },
    { name: "orders", type: "string[]" },
  ],
};

const value = {
  message: "Are you sure you want to cancel these orders",
  orders: [
    "0x550128e997978495eeae503c13e2e30243d747e969c65e1a0b565c609e097506",
  ],
};

const signature = await signer.signTypedData(domain, types, value);
```

Here we use ethers.js and show an example with MetaMask — any injected provider that exposes `eth_signTypedData_v4` will work.

> This signing scheme uses the [EIP-712 typed data standard](https://eips.ethereum.org/EIPS/eip-712).
