Skip to main content

Overview

SX Bet runs a full testnet environment (called Toronto) that mirrors mainnet. Use testnet to develop and test your integration without risking real funds, then switch to mainnet by updating a few configuration values.

Testnet setup

1. Create a testnet account

Sign up at toronto.sx.bet and export your private key from the assets page, the same way you would on mainnet.

2. Get testnet funds

Open a support chat on sx.bet to receive testnet USDC.

3. Enable betting on testnet

Approve the TokenTransferProxy on the testnet chain. The simplest way is to place a test bet through the toronto.sx.bet UI. To do it programmatically, see Enabling Betting — just use the testnet RPC URL and contract addresses below.

Configuration reference

Everything that differs between testnet and mainnet:
SettingTestnet (Toronto)Mainnet
API Base URLhttps://api.toronto.sx.bethttps://api.sx.bet
App URLhttps://toronto.sx.bethttps://sx.bet
Chain ID794799574162
RPC URLhttps://rpc-rollup.toronto.sx.technologyhttps://rpc-rollup.sx.technology
Explorer APIhttps://explorerl2.toronto.sx.technology/apihttps://explorerl2.sx.technology/api
USDC Address0x1BC6326EA6aF2aB8E4b6Bc83418044B1923b29560x6629Ce1Cf35Cc1329ebB4F63202F3f197b3F050B
Metadatahttps://api.toronto.sx.bet/metadatahttps://api.sx.bet/metadata
The executor, EIP712FillHasher, and TokenTransferProxy addresses are also different between environments. You can fetch them from the /metadata endpoint.

Structuring your code for easy switching

The cleanest approach is to store all environment-specific values in a config object and swap based on an environment variable:
import os

ENV = os.environ.get("SX_ENV", "testnet")

CONFIG = {
    "testnet": {
        "api_url": "https://api.toronto.sx.bet",
        "chain_id": 79479957,
        "rpc_url": "https://rpc-rollup.toronto.sx.technology",
        "usdc_address": "0x1BC6326EA6aF2aB8E4b6Bc83418044B1923b2956",
        "wsx_address": "0x5c02932f8422D943647682E95c87ea0333191e08",
        "explorer_api": "https://explorerl2.toronto.sx.technology/api",
    },
    "mainnet": {
        "api_url": "https://api.sx.bet",
        "chain_id": 4162,
        "rpc_url": "https://rpc-rollup.sx.technology",
        "usdc_address": "0x6629Ce1Cf35Cc1329ebB4F63202F3f197b3F050B",
        "wsx_address": "0x3E96B0a25d51e3Cc89C557f152797c33B839968f",
        "explorer_api": "https://explorerl2.sx.technology/api",
    },
}

cfg = CONFIG[ENV]

# Fetch executor and TokenTransferProxy from metadata — these differ per network
import requests
metadata = requests.get(f"{cfg['api_url']}/metadata").json()["data"]
cfg["executor"] = metadata["executorAddress"]
cfg["token_transfer_proxy"] = metadata["TokenTransferProxy"]
cfg["domain_version"] = metadata["domainVersion"]
cfg["eip712_fill_hasher"] = metadata["EIP712FillHasher"]
Then reference cfg everywhere instead of hardcoding values:
# API calls use cfg["api_url"]
markets = requests.get(f"{cfg['api_url']}/markets/active").json()

# Fill signing domain uses cfg["chain_id"] and values from metadata
DOMAIN = {
    "name": "SX Bet",
    "version": cfg["domain_version"],
    "chainId": cfg["chain_id"],
    "verifyingContract": cfg["eip712_fill_hasher"],
}

# Token addresses use cfg
base_token = cfg["usdc_address"]
To switch to mainnet, change one environment variable:
# Testnet (default)
SX_ENV=testnet node your-bot.js

# Mainnet
SX_ENV=mainnet node your-bot.js

Switching to mainnet checklist

When you’re ready to go live:
  • Set SX_ENV=mainnet (or update your config to use mainnet values)
  • Use your mainnet private key and API key (testnet keys won’t work on mainnet)
  • Fund your mainnet wallet with USDC
  • Approve the TokenTransferProxy on mainnet — either through sx.bet or programmatically
  • Confirm your fill signing domain uses chain ID 4162 and EIP712FillHasher from /metadata as verifyingContract
  • Test with a small order before scaling up

Common pitfalls

Wrong chain ID in signatures

If you see TAKER_SIGNATURE_MISMATCH or orders being rejected, check that your signing domain’s chainId matches the network you’re targeting. Testnet is 79479957, mainnet is 4162.

Wrong token addresses

USDC has different contract addresses on each network. Using a testnet token address on mainnet (or vice versa) will result in BAD_BASE_TOKEN errors.

Hardcoded executor or TokenTransferProxy

These addresses differ between networks. You can fetch them from GET /metadata at startup and cache them in your config.

Testnet API key on mainnet

API keys are network-specific. Generate a separate key for each environment.

References →

Full list of addresses, URLs, and chain IDs.

Enabling Betting →

Approve the TokenTransferProxy for trading.

Querying Balances →

Check your balance on either network.

Quickstart →

End-to-end guide from setup to first fill.