Overview

REST Single-Dimensional Credential allows you to fetch user data via RESTful APIs and validate user eligibility based on a single condition. It is suitable for when task verification is equivalent to answering the question, Did this particular user perform this task — yes or no?

If you want to understand the workflow and considerations of REST credentials, please refer to the introduction

Config process

1. Finding the Config in Task Settings

The option to configure REST credential can be found in step 3, Task Settings of quest creation on the Galxe Dashboard, under the Import Your Own Data task type.

2. Basic Config

  • ID Type

ID Type provides various identity options, including social accounts, blockchain addresses, and other unique identifiers.

  • Title

Give your credential a descriptive title relevant to the task at hand.

  • Credential Source

Choose REST type and select GET or POST based on your API request type.

  • Type

Choose Single Dimension.

3. Configure API

  • Input Endpoint URL

GET Request Example:

https://api.example.com/check-user?wallet=$address

POST Request Example:

https://api.example.com/check-user
  • Add Headers (Optional)
`Authorization`: `Bearer YOUR_API_KEY`
  • Input Body (For POST Requests Only):
{
  "check_user_address": "$address"
}

4. Test API Response

  • Input a test address, send the request, and confirm whether the response is correct.

  • The response must be in JSON format. Example:

  {
    "isWhitelisted": true,
    "balance": 1000
  }

5. Write Expressions

  1. Whitelist Validation:
   function(resp) {
       return resp.isWhitelisted ? 1 : 0;
   }
  1. Token Balance Validation:
   function(resp) {
       return resp.balance >= 1000 ? 1 : 0;
   }
  1. Combined Condition Validation:
   function(resp) {
       return resp.isWhitelisted && resp.balance >= 500 ? 1 : 0;
   }

6. Description

Description of the certificate, supports rich text input, maximum 200 characters.

Guide users to specific operation pages to complete interactive tasks.

8. Participation End Time & Update Frequency (Optional)

  • Participation End Time:

Control the time range of the credential, prohibiting new validations after the deadline.

  • Update Frequency:

Remind users of the frequency of API data source updates, such as once a day or once every two days.


Example

Polygon OAT Holder

  • Endpoint
https://api.covalenthq.com/v1/matic-mainnet/address/$address/collection/0x5D666F215a85B87Cb042D59662A7ecd2C8Cc44e6/
  • Request Type

GET

  • Headers
Authorization: Bearer YOU_API_KEY
  • Response
{
  "data": {
      "updated_at": "2023-06-26T05:12:35.553904397Z",
      "address": "0x123",
      "collection": "0x5d666f215a85b87cb042d59662a7ecd2c8cc44e6",
      "is_spam": false,
      "items": []
  },
  "error": false,
  "error_message": null,
  "error_code": null
}
  • Expression
function(resp) {
  if (resp.data.items != null && resp.data.items.length > 0) {
    return 1
  }
  return 0
}

ETH Balance Holder

  • Endpoint
https://mainnet.infura.io/v3/YOUR-API-KEY
  • Request Type

POST

  • Headers

No header

  • Body
{
    "jsonrpc": "2.0",
    "method": "eth_getBalance",
    "params": [
        "$address",
        "latest"
    ],
    "id": 1
}
  • Response
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x7c2562030800"
}

  • Expression
function(resp) {
  if (BigInt(resp.result) > 0) {
    return 1
  }
  return 0
}

General NFT Holder

  • Endpoint
https://mainnet.infura.io/v3/YOUR-API-KEY
  • Request Type

POST

  • Headers

No header

  • Body
{
  "jsonrpc":"2.0",
  "id":1,
  "method":"eth_call",
  "params":[
      {
        "data":"0x70a08231000000000000000000000000$addressWithout0x",
        "to":"0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB"
      },
      "latest"
  ]
}
  • Response
{
    "jsonrpc": "2.0",
    "id": 1,
    "result": "0x00000000000000000000000000000001"
}
  • Expression
function(resp) {
  if (BigInt(resp.result) > 0) {
    return 1
  }
  return 0
}