42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from py_clob_client.client import ClobClient
|
||
from eth_account import Account
|
||
|
||
# 启用助记词
|
||
Account.enable_unaudited_hdwallet_features()
|
||
|
||
# --- 配置 ---
|
||
HOST = "https://clob.polymarket.com"
|
||
MNEMONIC = "material vapor okay save company news village license head slogan sadness wire"
|
||
|
||
|
||
def auto_redeem():
|
||
try:
|
||
acct = Account.from_mnemonic(MNEMONIC)
|
||
client = ClobClient(HOST, key=acct.key.hex(), chain_id=137)
|
||
client.set_api_creds(client.create_or_derive_api_creds())
|
||
|
||
print(f"✅ 钱包地址: {acct.address}")
|
||
|
||
# 在新版 SDK 中,领奖函数通常是 redeem (不带 post_)
|
||
# 或者 post_redeem_positions
|
||
print("📡 尝试发送领奖请求...")
|
||
|
||
try:
|
||
# 方案 A: 最新版标准方法
|
||
resp = client.redeem()
|
||
except AttributeError:
|
||
# 方案 B: 兼容部分子版本
|
||
resp = client.post_redeem_positions()
|
||
|
||
if resp and resp.get("success"):
|
||
print("🚀 领奖成功!USDC 应该已回到你的可用余额中。")
|
||
else:
|
||
print(f"ℹ️ 状态提示: {resp}")
|
||
|
||
except Exception as e:
|
||
print(f"❌ 运行出错: {e}")
|
||
print("💡 提示:如果此报错是 AttributeError,说明你目前没有可领取的奖金,或者该市场已自动结算。")
|
||
|
||
|
||
if __name__ == "__main__":
|
||
auto_redeem() |