领取返佣
链下领取
将待领取的链下返佣划转到账户余额(即时到账,无需链上操作)。
POST /referral/claim
Authorization: Bearer <token>
Content-Type: application/json
请求体
空对象 {}。
响应
{
"success": true,
"amount": "45.00",
"tx_hash": null
}
| 字段 | 类型 | 说明 |
|---|---|---|
success | bool | 是否成功 |
amount | Decimal | 本次到账金额(USDT) |
tx_hash | null | 链下结算,始终为 null |
错误码
| HTTP | 错误码 | 说明 |
|---|---|---|
| 400 | NO_PENDING_EARNINGS | 无待领取收益 |
| 400 | BELOW_MINIMUM | 待领取金额低于最低限额(10 USDT) |
| 500 | DB_ERROR | 服务端错误 |
获取链上 Claim 签名
为当前用户生成 EIP-712 签名,用于在链上合约调用 claimRebate(amount, deadline, signature)。
POST /referral/on-chain/claim-signature
Authorization: Bearer <token>
Content-Type: application/json
请求体
{
"amount": "50.00"
}
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
amount | string | 是 | 申请 Claim 的 USDT 金额(必须 > 0) |
响应
{
"amount": "50000000",
"nonce": 0,
"deadline": 1772097006,
"signature": "0x9efb5f986acf3dafdd...",
"contract_address": "0x..."
}
| 字段 | 类型 | 说明 |
|---|---|---|
amount | string | 金额(链上 USDT 精度,6 位,即 amount × 10^6) |
nonce | uint64 | 当前用户 nonce |
deadline | uint64 | 签名有效期(Unix 时间戳,秒) |
signature | string | 后端 EIP-712 签名 |
contract_address | string | ReferralRebate 合约地址 |
合约调用
// claimRebate(uint256 amount, uint256 deadline, bytes signature)
ReferralRebate(contractAddress).claimRebate(amount, deadline, signature)
错误码
| HTTP | 错误码 | 说明 |
|---|---|---|
| 400 | INVALID_AMOUNT | 金额格式无效或 ≤ 0 |
| 500 | SIGNATURE_ERROR | 签名生成失败 |
| 500 | CONFIG_ERROR | 后端 Signer 私钥未配置 |
代码示例
Python — Off-Chain Claim
import requests
BASE_URL = "https://api.ztdx.io"
JWT_TOKEN = "your_jwt_token"
resp = requests.post(
f"{BASE_URL}/referral/claim",
headers={"Authorization": f"Bearer {JWT_TOKEN}", "Content-Type": "application/json"},
json={},
)
data = resp.json()
print(f"Claimed: {data['amount']} USDT, success={data['success']}")
Python — On-Chain Claim Signature
import requests
BASE_URL = "https://api.ztdx.io"
JWT_TOKEN = "your_jwt_token"
resp = requests.post(
f"{BASE_URL}/referral/on-chain/claim-signature",
headers={"Authorization": f"Bearer {JWT_TOKEN}", "Content-Type": "application/json"},
json={"amount": "50.00"},
)
data = resp.json()
print(f"Amount (Wei): {data['amount']}, Nonce: {data['nonce']}, Deadline: {data['deadline']}")
print(f"Signature: {data['signature']}")
print(f"Contract: {data['contract_address']}")
# Use this signature to call ReferralRebate.claimRebate(amount, deadline, signature) on-chain