Skip to main content

Overview

SX Bet provides a blockchain explorer API that lets you query your USDC balance.

Base URL

https://explorerl2.sx.technology/api
For testnet:
https://explorerl2.toronto.sx.technology/api

Check your USDC balance

Query your ERC-20 token balance using the tokenbalance action. You need the token contract address and your wallet address.
import requests

EXPLORER_API = "https://explorerl2.sx.technology/api"
USDC_ADDRESS = "0x6629Ce1Cf35Cc1329ebB4F63202F3f197b3F050B"
WALLET = "0xYourWalletAddress"

response = requests.get(EXPLORER_API, params={
    "module": "account",
    "action": "tokenbalance",
    "contractaddress": USDC_ADDRESS,
    "address": WALLET,
})

result = response.json()
raw_balance = int(result["result"])
usdc_balance = raw_balance / 10**6  # USDC has 6 decimals
print(f"USDC balance: {usdc_balance:.2f}")
Response:
{
  "message": "OK",
  "status": "1",
  "result": "135499"
}
The result is the raw token balance. Divide by 10^decimals to get the human-readable amount (USDC = 6 decimals). See Unit Conversion for more on token decimals.

Token addresses

TokenMainnetTestnet
USDC0x6629Ce1Cf35Cc1329ebB4F63202F3f197b3F050B0x1BC6326EA6aF2aB8E4b6Bc83418044B1923b2956
See References for the full list of addresses and network details.

Unit Conversion →

Converting between raw token values and human-readable amounts.

References →

Contract addresses, RPC URLs, and chain IDs.

Enabling Betting →

Approve the TokenTransferProxy before placing bets.

Filling Orders →

Use your balance to fill orders as a taker.