Files
mini_code/polymarket/领取奖励.py
2026-01-04 00:54:44 +08:00

42 lines
1.4 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 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()