Subscribe & Redeem
Subscribe Flow
The subscription process involves both backend API calls and on-chain contract interactions:
┌──────────┐ ① GET /earn/products ┌──────────────┐
│ Client │ ───────────────────────▶ │ Public API │
│ │ ◀─────────────────────── │ │
│ │ Product list └──────────────┘
│ │
│ │ ② POST /earn/subscribe/prepare
│ │ ───────────────────────▶ ┌──────────────┐
│ │ ◀─────────────────────── │ Protected API│
│ │ EIP-712 signature └──────────────┘
│ │
│ │ ③ approve USDT
│ │ ───────────────────────▶ ┌──────────────┐
│ │ │ USDT Contract│
│ │ ④ call subscribe() └──────────────┘
│ │ ───────────────────────▶ ┌──────────────┐
│ │ │ Earn Contract│
└──────────┘ └──────┬───────┘
│ ⑤ Subscribed Event
▼
┌──────────────┐
│ Backend │
│ Creates record│
│ Mints NFT │
└──────────────┘
Step 1: Get EIP-712 Domain
GET /earn/domain
Response
{
"types": {
"EIP712Domain": [
{ "name": "name", "type": "string" },
{ "name": "version", "type": "string" },
{ "name": "chainId", "type": "uint256" },
{ "name": "verifyingContract", "type": "address" }
],
"Subscribe": [
{ "name": "user", "type": "address" },
{ "name": "productId", "type": "uint256" },
{ "name": "amount", "type": "uint256" },
{ "name": "deadline", "type": "uint256" }
]
},
"primaryType": "Subscribe",
"domain": {
"name": "Primit Earn",
"version": "1",
"chainId": 421614,
"verifyingContract": "0x436dcB8a2478D636a6cC678AE7A2E4c5449cB3ba"
}
}
Step 2: Browse Products
GET /earn/products
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
status | string | No | Filter by status: created / subscribing / active / settled / ended / cancelled |
page | number | No | Page number, default 1 |
page_size | number | No | Items per page, default 20 |
Example
GET /earn/products?status=subscribing&page=1&page_size=10
Response
{
"products": [
{
"id": "123204f6-5bde-4434-890a-8ca241f66067",
"chain_product_id": 1769524310,
"name": "USDT Earn 900% APY",
"description": null,
"annual_rate": "900.00%",
"period_rate": "0.00%",
"annual_rate_bps": 90000,
"period_rate_bps": 0,
"duration_seconds": 300,
"total_quota": "500000000.00",
"subscribed_amount": "500000000.00",
"available_quota": "0.00",
"subscription_rate": "100.00%",
"min_amount": "100000000.00",
"max_amount_per_user": "500000000.00",
"status": "subscribing",
"subscriber_count": 1,
"subscribe_start_time": "2026-01-27T14:33:00Z",
"subscribe_end_time": "2026-01-27T14:38:00Z",
"settle_time": "2026-01-27T14:43:00Z",
"is_subscribing": true,
"is_sold_out": false,
"time_remaining_seconds": 180
}
],
"total": 1,
"page": 1,
"page_size": 20
}
Product Fields (ProductDetail)
| Field | Type | Description |
|---|---|---|
id | string | Product UUID |
chain_product_id | number | On-chain product ID |
name | string | Product name |
description | string | null | Product description |
annual_rate | string | Annual yield (percentage string) |
period_rate | string | Period yield (percentage string) |
annual_rate_bps | number | Annual rate in basis points (1% = 100) |
period_rate_bps | number | Period rate in basis points |
duration_seconds | number | Lock duration in seconds |
total_quota | string | Total subscription cap (Wei) |
subscribed_amount | string | Total subscribed amount (Wei) |
available_quota | string | Remaining available quota (Wei) |
subscription_rate | string | Subscription progress percentage |
min_amount | string | Minimum subscription amount (Wei) |
max_amount_per_user | string | Maximum per-user subscription (Wei) |
status | string | Product status |
subscriber_count | number | Number of subscribers |
subscribe_start_time | string | Subscription start time (ISO 8601) |
subscribe_end_time | string | Subscription end time (ISO 8601) |
settle_time | string | Settlement time (ISO 8601) |
is_subscribing | boolean | Whether currently in subscription period |
is_sold_out | boolean | Whether fully subscribed |
time_remaining_seconds | number | null | Seconds remaining in subscription window (only during subscription period) |
Step 3: Get Product Details
GET /earn/products/:id
| Parameter | Type | Description |
|---|---|---|
id | string | Product UUID or chain_product_id (integer string) |
Returns a ProductDetail object (same fields as product list).