Create Referral Code
Generate the account's unique 8-character referral code (uppercase hex, e.g. 4DDDC2D4). One code per account; it cannot be changed or deleted.
POST /referral/codes
Content-Type: application/json
Auth: Authorization: Bearer <JWT> from the EIP-712 login. API keys are not accepted.
Request body
{ "signature": "0x...", "timestamp": 1772010600 }
| Field | Type | Required | Description |
|---|---|---|---|
signature | string | yes | EIP-712 signature (below) |
timestamp | uint64 | yes | Unix seconds, ±5 min |
EIP-712 message
{
"primaryType": "CreateReferralCode",
"types": {
"CreateReferralCode": [
{ "name": "wallet", "type": "address" },
{ "name": "timestamp", "type": "uint256" }
]
},
"domain": "<typed_data.domain from GET /auth/nonce/{address}>",
"message": { "wallet": "0x<your_address>", "timestamp": 1772010600 }
}
The signature is verified: the recovered signer must equal the JWT's wallet address, and timestamp (seconds) must be within ±5 minutes.
Response
{ "success": true, "code": "4DDDC2D4", "created_at": 1772010604000 }
Errors
| HTTP | code |
|---|---|
| 400 | TIMESTAMP_EXPIRED, INVALID_SIGNATURE_FORMAT |
| 401 | SIGNATURE_INVALID |
| 409 | CODE_ALREADY_EXISTS |
| 500 | DB_ERROR, CREATE_FAILED |
Python
import time, requests
from eth_account import Account
from eth_account.messages import encode_typed_data
BASE = "https://api-avax.<sparky-domain>/api/v1"
acct = Account.from_key("0xYourPrivateKey"); addr = acct.address.lower()
domain = requests.get(f"{BASE}/auth/nonce/{addr}").json()["typed_data"]["domain"]
ts = int(time.time())
typed = {
"types": {
"EIP712Domain": [
{"name": "name", "type": "string"}, {"name": "version", "type": "string"},
{"name": "chainId", "type": "uint256"}, {"name": "verifyingContract", "type": "address"},
],
"CreateReferralCode": [{"name": "wallet", "type": "address"}, {"name": "timestamp", "type": "uint256"}],
},
"primaryType": "CreateReferralCode",
"domain": domain,
"message": {"wallet": addr, "timestamp": ts},
}
sig = "0x" + acct.sign_message(encode_typed_data(full_message=typed)).signature.hex().removeprefix("0x")
r = requests.post(f"{BASE}/referral/codes", json={"signature": sig, "timestamp": ts},
headers={"Authorization": f"Bearer {JWT_TOKEN}"})
print(r.json())