Files
mini_code/polymarket/检查usdc.py
2026-01-04 00:54:44 +08:00

32 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from web3 import Web3
RPC_URL = "https://polygon-rpc.com"
MY_ADDRESS = "0xADcA20376A6CdCBd232577ac830F4116eC863DcF"
# 两个不同的 USDC 地址
USDC_E_ADDR = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174" # 桥接版 (Polymarket用这个)
USDC_NATIVE_ADDR = "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359" # 原生版
w3 = Web3(Web3.HTTPProvider(RPC_URL))
abi = [{"constant": True, "inputs": [{"name": "_owner", "type": "address"}], "name": "balanceOf",
"outputs": [{"name": "balance", "type": "uint256"}], "type": "function"}]
def check():
# 检查 USDC.e
c_e = w3.eth.contract(address=w3.to_checksum_address(USDC_E_ADDR), abi=abi)
bal_e = c_e.functions.balanceOf(MY_ADDRESS).call() / 1e6
# 检查 原生 USDC
c_n = w3.eth.contract(address=w3.to_checksum_address(USDC_NATIVE_ADDR), abi=abi)
bal_n = c_n.functions.balanceOf(MY_ADDRESS).call() / 1e6
print(f"💰 桥接版 USDC.e (旧): {bal_e} USDC")
print(f"💰 原生版 USDC (新): {bal_n} USDC")
if bal_n > 0 and bal_e == 0:
print("\n⚠️ 发现原因:你的 USDC 是新版原生币Polymarket 不支持!")
print("💡 解决方法:在 OKX 钱包里使用 Swap 功能,把 USDC 兑换成 USDC.e")
check()