Claim Earnings
Off-Chain Claim
Transfer pending off-chain referral earnings to the user's account balance. This is instant and requires no on-chain transaction.
POST /referral/claim
Authorization: Bearer <token>
Content-Type: application/json
Request Body
Empty object {}.
Response
{
"success": true,
"amount": "45.00",
"tx_hash": null
}
| Field | Type | Description |
|---|---|---|
success | bool | Whether the claim succeeded |
amount | Decimal | Amount credited to account (USDT) |
tx_hash | null | Always null for off-chain settlement |
Error Codes
| HTTP | Code | Description |
|---|---|---|
| 400 | NO_PENDING_EARNINGS | No pending earnings to claim |
| 400 | BELOW_MINIMUM | Pending amount is below 10 USDT minimum |
| 500 | DB_ERROR | Server error |
On-Chain Claim Signature
Generate an EIP-712 signature for the user to call claimRebate on the ReferralRebate smart contract.
POST /referral/on-chain/claim-signature
Authorization: Bearer <token>
Content-Type: application/json
Request Body
{
"amount": "50.00"
}
| Field | Type | Required | Description |
|---|---|---|---|
amount | string | Yes | USDT amount to claim (must be > 0) |
Response
{
"amount": "50000000",
"nonce": 0,
"deadline": 1772097006,
"signature": "0x9efb5f986acf3dafdd...",
"contract_address": "0x..."
}
| Field | Type | Description |
|---|---|---|
amount | string | Amount in on-chain USDT precision (6 decimals, i.e., amount × 10^6) |
nonce | uint64 | Current user nonce (increments after each on-chain claim) |
deadline | uint64 | Signature expiry (Unix timestamp, seconds) |
signature | string | Backend-generated EIP-712 signature |
contract_address | string | ReferralRebate contract address |
Smart Contract Call
// claimRebate(uint256 amount, uint256 deadline, bytes signature)
ReferralRebate(contractAddress).claimRebate(amount, deadline, signature)
Error Codes
| HTTP | Code | Description |
|---|---|---|
| 400 | INVALID_AMOUNT | Amount format is invalid or ≤ 0 |
| 500 | SIGNATURE_ERROR | Failed to generate claim signature |
| 500 | CONFIG_ERROR | Backend signer key not configured |
Code Examples
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