Skip to main content

Token Statistics Operations

This document provides detailed information about the GraphQL operations available for managing token statistics in the CRM application.

Queries​

tokenStat​

Retrieves token statistics for a specific token (defaults to BLOCK).

query TokenStat($token: TokenName) {
tokenStat(token: $token) {
_id
token
monthlyBuyBackHistory {
_id
month
year
revenue
multiplier
createdAt
updatedAt
}
tiersData {
bronze
silver
gold
platinum
diamond
rewardPercent
tokenBurnPercent
companyPercent
}
buyBackTiers {
_id
tier
month
info {
lang
text
}
description {
lang
text
}
createdAt
updatedAt
}
userGrowth {
_id
month
year
activeUsers
createdAt
updatedAt
}
socials {
_id
name
month
year
subscribers
createdAt
updatedAt
}
multipliers {
_id
month
year
tier
multiplier
createdAt
updatedAt
}
tokenSupply {
title {
lang
text
}
description {
lang
text
}
maxSupply
circulatingSupply
burned
}
}
}

Variables:

{
"token": "BLOCK" // Optional, defaults to BLOCK if not provided
}

Access Control:

  • Requires OWNER, CMS, or BO role

tokenStats​

Retrieves statistics for all tokens.

query TokenStats {
tokenStats {
_id
token
# Include fields as needed, similar to tokenStat query
}
}

Access Control:

  • Requires OWNER, CMS, or BO role

Mutations​

createTokenStat​

Creates a new token statistics entry.

mutation CreateTokenStat($input: CreateTokenStatInput!) {
createTokenStat(input: $input) {
_id
token
# Include other fields as needed
}
}

Variables:

{
"input": {
"token": "BLOCK"
}
}

Access Control:

  • Requires OWNER role

addUpdateMonthlyBuyBack​

Adds or updates monthly buyback data.

mutation AddUpdateMonthlyBuyBack($input: AddUpdateMonthlyBuyBackInput!) {
addUpdateMonthlyBuyBack(input: $input)
}

Variables for Create:

{
"input": {
"token": "BLOCK",
"month": 6,
"year": 2023,
"revenue": 1000000,
"multiplier": 0.5
}
}

Variables for Update:

{
"input": {
"id": "60d21b4667d0d8992e610c85",
"token": "BLOCK",
"month": 6,
"year": 2023,
"revenue": 1200000,
"multiplier": 0.6
}
}

Access Control:

  • Requires OWNER, CMS, or BO role

addUpdateBuybackTiers​

Adds or updates buyback tier information with multilingual support.

mutation AddUpdateBuybackTiers($input: AddUpdateBuyBackTiersInput!) {
addUpdateBuybackTiers(input: $input) {
success
contentGeneratedWithSuccess
}
}

Variables for Create:

{
"input": {
"token": "BLOCK",
"tier": 1,
"month": 6,
"info": [
{
"lang": "EN",
"text": "Tier 1 info in English"
}
],
"description": [
{
"lang": "EN",
"text": "Tier 1 description in English"
}
]
}
}

Variables for Update:

{
"input": {
"id": "60d21b4667d0d8992e610c85",
"token": "BLOCK",
"tier": 1,
"month": 6,
"info": [
{
"lang": "EN",
"text": "Updated tier 1 info in English"
},
{
"lang": "ES",
"text": "Información de nivel 1 en español"
}
],
"description": [
{
"lang": "EN",
"text": "Updated tier 1 description in English"
},
{
"lang": "ES",
"text": "Descripción de nivel 1 en español"
}
]
}
}

Access Control:

  • Requires OWNER, CMS, or BO role

Features:

  • When creating a new tier with a single language, the system will automatically translate the content to all supported languages

createUpdateTiersData​

Creates or updates tier-related data.

mutation CreateUpdateTiersData($input: CreateUpdateTiersDataInput!) {
createUpdateTiersData(input: $input)
}

Variables:

{
"input": {
"token": "BLOCK",
"bronze": 10000,
"silver": 50000,
"gold": 100000,
"platinum": 500000,
"diamond": 1000000,
"rewardPercent": 70,
"tokenBurnPercent": 20,
"companyPercent": 10
}
}

Access Control:

  • Requires OWNER, CMS, or BO role

createUpdateTokenSupply​

Updates token supply information with multilingual descriptions.

mutation CreateUpdateTokenSupply($input: CreateUpdateTokenSupplyInput!) {
createUpdateTokenSupply(input: $input)
}

Variables:

{
"input": {
"token": "BLOCK",
"title": [
{
"lang": "EN",
"text": "Token Supply Information"
}
],
"description": [
{
"lang": "EN",
"text": "Details about the token supply and circulation."
}
],
"maxSupply": 100000000,
"circulatingSupply": 60000000,
"burned": 5000000
}
}

Access Control:

  • Requires OWNER, CMS, or BO role

Features:

  • When providing only one language for title and description, the system will automatically translate the content to all supported languages

addUpdateUserGrowth​

Adds or updates user growth statistics.

mutation AddUpdateUserGrowth($input: AddUpdateUserGrowthInput!) {
addUpdateUserGrowth(input: $input)
}

Variables for Create:

{
"input": {
"token": "BLOCK",
"month": 6,
"year": 2023,
"activeUsers": 25000
}
}

Variables for Update:

{
"input": {
"id": "60d21b4667d0d8992e610c85",
"token": "BLOCK",
"month": 6,
"year": 2023,
"activeUsers": 27500
}
}

Access Control:

  • Requires OWNER, CMS, or BO role

addUpdateTokenMultipliers​

Adds or updates token multiplier information.

mutation AddUpdateTokenMultipliers($input: AddUpdateTokenMultipliersInput!) {
addUpdateTokenMultipliers(input: $input)
}

Variables for Create:

{
"input": {
"token": "BLOCK",
"month": 6,
"year": 2023,
"tier": 1,
"multiplier": 0.5
}
}

Variables for Update:

{
"input": {
"id": "60d21b4667d0d8992e610c85",
"token": "BLOCK",
"month": 6,
"year": 2023,
"tier": 1,
"multiplier": 0.6
}
}

Access Control:

  • Requires OWNER, CMS, or BO role

addUpdateSocialStats​

Adds or updates social media statistics.

mutation AddUpdateSocialStats($input: AddUpdateSocialSubscribersInput!) {
addUpdateSocialStats(input: $input)
}

Variables for Create:

{
"input": {
"token": "BLOCK",
"name": "Twitter",
"month": 6,
"year": 2023,
"subscribers": 50000
}
}

Variables for Update:

{
"input": {
"id": "60d21b4667d0d8992e610c85",
"token": "BLOCK",
"name": "Twitter",
"month": 6,
"year": 2023,
"subscribers": 55000
}
}

Access Control:

  • Requires OWNER, CMS, or BO role

Error Handling​

Common Errors​

  • Unauthorized Access: If the user doesn't have the required role

    {
    "errors": [
    {
    "message": "Forbidden resource",
    "extensions": {
    "code": "FORBIDDEN"
    }
    }
    ]
    }
  • Validation Error: If input validation fails

    {
    "errors": [
    {
    "message": "month must not be greater than 12",
    "extensions": {
    "code": "BAD_USER_INPUT"
    }
    }
    ]
    }
  • Duplicate Entry: When attempting to create a duplicate entry

    {
    "data": {
    "addUpdateMonthlyBuyBack": false
    }
    }

Best Practices​

  1. Use TokenName Enum: Always use the correct token name from the TokenName enum
  2. Date Validation: Ensure month (1-12) and year (2020-2100) values are within valid ranges
  3. Tier Validation: Ensure tier values (1-5) are valid
  4. Language Consistency: When providing multilingual content manually, ensure consistency across languages
  5. Check Return Values: Always check mutation return values to confirm success