Skip to main content
POST
/
api
/
referrals
Referrals API
curl --request POST \
  --url https://unidexv4-api-production.up.railway.app/api/referrals \
  --header 'Content-Type: application/json' \
  --data '{
  "action": "getCodeInfo",
  "code": "<string>",
  "userAddress": "<string>"
}'
{
  "code": "<string>",
  "bytes32Code": "<string>",
  "owner": "<string>",
  "isClaimed": true
}

Overview

The Referrals API allows users to check referral code information and claim new referral codes on the UniDex platform.

Request Body

action
string
required
Action to perform. Must be one of:
  • getCodeInfo: Get information about a referral code
  • claimCode: Generate calldata to claim a referral code
code
string
required
The referral code to check or claim
userAddress
string
Required for claimCode action. Ethereum address of the user claiming the code

Response Fields

For getCodeInfo action

code
string
The referral code
bytes32Code
string
32-byte representation of the referral code
owner
string
Address of the code owner, or “Code not claimed” if unclaimed
isClaimed
boolean
Whether the code has been claimed

For claimCode action

calldata
string
Encoded function call data for claiming the code
contractAddress
string
Address of the referral contract
code
string
The referral code being claimed
bytes32Code
string
32-byte representation of the referral code

Example Usage

Check Code Information

curl -X POST "https://unidexv4-api-production.up.railway.app/api/referrals" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "getCodeInfo",
    "code": "MYREFERRALCODE"
}'

Claim Code

curl -X POST "https://unidexv4-api-production.up.railway.app/api/referrals" \
  -H "Content-Type: application/json" \
  -d '{
    "action": "claimCode",
    "code": "MYREFERRALCODE",
    "userAddress": "0x1234567890123456789012345678901234567890"
}'

Example Responses

For getCodeInfo

{
  "code": "MYREFERRALCODE",
  "bytes32Code": "0x4d59524546455252414c434f44450000000000000000000000000000000000",
  "owner": "0x1234567890123456789012345678901234567890",
  "isClaimed": true
}

For unclaimed code

{
  "code": "MYREFERRALCODE",
  "bytes32Code": "0x4d59524546455252414c434f44450000000000000000000000000000000000",
  "owner": "Code not claimed",
  "isClaimed": false
}

For claimCode

{
  "calldata": "0x4d59524546455252414c434f4445000000000000000000000000000000000000",
  "contractAddress": "0xe3ca135782e4a17aFb31a63ee3b15351C891A1A2",
  "code": "MYREFERRALCODE",
  "bytes32Code": "0x4d59524546455252414c434f44450000000000000000000000000000000000"
}

Error Responses

The endpoint will return appropriate error messages for:
  • Missing action ({"error": "Missing action"})
  • Missing code for getCodeInfo ({"error": "Missing code"})
  • Missing code or userAddress for claimCode ({"error": "Missing code or userAddress"})
  • Invalid userAddress ({"error": "Invalid userAddress"})
  • Already claimed referral code ({"error": "Referral code is already claimed"})

Body

application/json
action
enum<string>
required

Action to perform

Available options:
getCodeInfo,
claimCode
code
string
required

Referral code

userAddress
string

Required for claimCode action

Response

Successful response

  • Option 1
  • Option 2
code
string
required

The referral code

bytes32Code
string
required

32-byte representation of the code

owner
string
required

Address of code owner or 'Code not claimed'

isClaimed
boolean
required

Whether the code has been claimed

I