API
Check Rewards

Check Rewards

Check pending trading rewards for any token created through Digifi without executing a transaction.

Overview

The /checkRewards endpoint allows you to:

  • Preview pending rewards without claiming
  • Monitor trading fees accumulated
  • View token and ETH rewards separately
  • Check LP initialization status
  • Verify fee distribution addresses

This is a read-only operation that uses staticCall() to simulate the transaction without executing it. No gas fees are required.

Endpoint

GET /checkRewards

Request

Headers

Authorization: Bearer YOUR_API_KEY

Query Parameters

ParameterTypeRequiredDescription
tokenAddressstringYesToken contract address (0x...)
apiKeystringYesYour Digifi API key

Example Request

curl -X GET "https://api.digifi.fun/checkRewards?tokenAddress=0x937f6Af292875cC2a3b64bFC31B09d5A50B1cF1a&apiKey=dg_YOUR_API_KEY" \
  -H "Authorization: Bearer dg_YOUR_API_KEY"

Response

Success Response (200)

{
  "success": true,
  "tokenAddress": "0x937f6Af292875cC2a3b64bFC31B09d5A50B1cF1a",
  "tokenName": "Hi-hat Token",
  "tokenSymbol": "HIHAT",
  "lpInitialized": true,
  "lpTokenId": "518214",
  "network": {
    "name": "base",
    "chainId": "8453"
  },
  "pendingRewards": {
    "tokenRewards": "24.35",
    "tokenRewardsWei": "24350000000000000000",
    "ethRewards": "0.0000834",
    "ethRewardsWei": "83400000000000",
    "feeReceiver": "0x1ab186D064171DB900fa6701A3eF5C5153ecbC24",
    "factoryCreator": "0x3B1601C4e82B19beb3886A6A74b3C89Ef28bD67F"
  },
  "checkedBy": "yourUsername",
  "checkedAt": "2025-11-07T12:00:00.000Z"
}

LP Not Initialized Response (200)

{
  "success": true,
  "tokenAddress": "0x...",
  "lpInitialized": false,
  "tokenRewards": "0",
  "ethRewards": "0",
  "message": "LP not yet initialized for this token"
}

Error Responses

Invalid Token Address (400)

{
  "error": "Invalid token address",
  "details": "No contract found at the provided address on Base",
  "network": {
    "name": "base",
    "chainId": "8453",
    "expectedChain": "Base Mainnet (chainId: 8453)"
  }
}

Invalid Contract (400)

{
  "error": "Invalid contract",
  "details": "Contract does not appear to be a SimpleToken with the expected interface",
  "contractAddress": "0x...",
  "network": {
    "name": "base",
    "chainId": "8453"
  },
  "hint": "Make sure this is a token deployed through the V4 factory on Base"
}

Invalid API Key (401)

{
  "error": "Invalid API key"
}

Response Fields

FieldTypeDescription
successbooleanWhether the check was successful
tokenAddressstringToken contract address checked
tokenNamestringName of the token
tokenSymbolstringSymbol of the token
lpInitializedbooleanWhether liquidity pool is initialized
lpTokenIdstringLiquidity position NFT ID
network.namestringNetwork name (e.g., "base")
network.chainIdstringChain ID (e.g., "8453")
pendingRewards.tokenRewardsstringToken rewards in human-readable format
pendingRewards.tokenRewardsWeistringToken rewards in wei (18 decimals)
pendingRewards.ethRewardsstringETH rewards in human-readable format
pendingRewards.ethRewardsWeistringETH rewards in wei
pendingRewards.feeReceiverstringAddress that receives token fees (creator)
pendingRewards.factoryCreatorstringAddress that receives ETH fees (platform)
checkedBystringUsername of API key holder who checked
checkedAtstringISO timestamp of when rewards were checked

Code Examples

JavaScript / Node.js

const axios = require("axios");
 
const checkRewards = async (tokenAddress) => {
  try {
    const apiKey = process.env.DIGIFI_API_KEY;
    
    const response = await axios.get("https://api.digifi.fun/checkRewards", {
      params: {
        tokenAddress: tokenAddress,
        apiKey: apiKey,
      },
      headers: {
        Authorization: `Bearer ${apiKey}`,
      },
    });
 
    const data = response.data;
 
    if (data.success) {
      console.log(`Token: ${data.tokenName} (${data.tokenSymbol})`);
      console.log(`Network: ${data.network.name} (Chain ${data.network.chainId})`);
 
      if (data.lpInitialized) {
        console.log(`\nPending Rewards:`);
        console.log(`  Token: ${data.pendingRewards.tokenRewards} ${data.tokenSymbol}`);
        console.log(`  ETH: ${data.pendingRewards.ethRewards} ETH`);
        console.log(`\nFee Recipients:`);
        console.log(`  Creator → ${data.pendingRewards.feeReceiver}`);
        console.log(`  Platform → ${data.pendingRewards.factoryCreator}`);
      } else {
        console.log("LP not yet initialized");
      }
    }
 
    return data;
  } catch (error) {
    console.error("Error:", error.response?.data || error.message);
    throw error;
  }
};
 
// Usage
checkRewards("0x937f6Af292875cC2a3b64bFC31B09d5A50B1cF1a");
 
// Auto-refresh every 30 seconds
setInterval(() => {
  checkRewards("0x937f6Af292875cC2a3b64bFC31B09d5A50B1cF1a");
}, 30000);

Python

import requests
import os
import time
 
def check_rewards(token_address):
    url = 'https://api.digifi.fun/checkRewards'
    
    api_key = os.getenv('DIGIFI_API_KEY')
    
    params = {
        'tokenAddress': token_address,
        'apiKey': api_key
    }
    
    headers = {
        'Authorization': f'Bearer {api_key}'
    }
    
    try:
        response = requests.get(url, params=params, headers=headers)
        response.raise_for_status()
        
        data = response.json()
        
        if data['success']:
            print(f"Token: {data['tokenName']} ({data['tokenSymbol']})")
            print(f"Network: {data['network']['name']} (Chain {data['network']['chainId']})")
            
            if data['lpInitialized']:
                print(f"\nPending Rewards:")
                print(f"  Token: {data['pendingRewards']['tokenRewards']} {data['tokenSymbol']}")
                print(f"  ETH: {data['pendingRewards']['ethRewards']} ETH")
                print(f"\nFee Recipients:")
                print(f"  Creator → {data['pendingRewards']['feeReceiver']}")
                print(f"  Platform → {data['pendingRewards']['factoryCreator']}")
            else:
                print('LP not yet initialized')
        
        return data
    except requests.exceptions.RequestException as e:
        print(f'Error: {e}')
        raise
 
# Usage
check_rewards('0x937f6Af292875cC2a3b64bFC31B09d5A50B1cF1a')
 
# Auto-refresh every 30 seconds
while True:
    check_rewards('0x937f6Af292875cC2a3b64bFC31B09d5A50B1cF1a')
    time.sleep(30)

TypeScript

interface PendingRewards {
  tokenRewards: string;
  tokenRewardsWei: string;
  ethRewards: string;
  ethRewardsWei: string;
  feeReceiver: string;
  factoryCreator: string;
}
 
interface NetworkInfo {
  name: string;
  chainId: string;
}
 
interface CheckRewardsResponse {
  success: boolean;
  tokenAddress: string;
  tokenName: string;
  tokenSymbol: string;
  lpInitialized: boolean;
  lpTokenId?: string;
  network: NetworkInfo;
  pendingRewards?: PendingRewards;
  checkedBy: string;
  checkedAt: string;
  message?: string;
}
 
const checkRewards = async (
  tokenAddress: string
): Promise<CheckRewardsResponse> => {
  const apiKey = process.env.DIGIFI_API_KEY;
  
  const url = new URL("https://api.digifi.fun/checkRewards");
  url.searchParams.append("tokenAddress", tokenAddress);
  url.searchParams.append("apiKey", apiKey!);
 
  const response = await fetch(url.toString(), {
    method: "GET",
    headers: {
      Authorization: `Bearer ${apiKey}`,
    },
  });
 
  if (!response.ok) {
    const error = await response.json();
    throw new Error(error.error || "Failed to check rewards");
  }
 
  const data: CheckRewardsResponse = await response.json();
 
  if (data.success && data.lpInitialized && data.pendingRewards) {
    console.log(`Token: ${data.tokenName} (${data.tokenSymbol})`);
    console.log(`Network: ${data.network.name} (Chain ${data.network.chainId})`);
    console.log(`Token Rewards: ${data.pendingRewards.tokenRewards} ${data.tokenSymbol}`);
    console.log(`ETH Rewards: ${data.pendingRewards.ethRewards} ETH`);
  }
 
  return data;
};
 
// Usage with auto-refresh
const autoRefreshRewards = async (
  tokenAddress: string,
  intervalMs: number = 30000
) => {
  const refresh = async () => {
    try {
      const rewards = await checkRewards(tokenAddress);
      return rewards;
    } catch (error) {
      console.error("Error refreshing rewards:", error);
    }
  };
 
  await refresh();
  return setInterval(refresh, intervalMs);
};
 
// Start auto-refresh
const intervalId = await autoRefreshRewards(
  "0x937f6Af292875cC2a3b64bFC31B09d5A50B1cF1a"
);
 
// Stop auto-refresh when done
// clearInterval(intervalId);

How It Works

Read-Only Simulation

The endpoint uses staticCall() to:

  1. Connect to Base Mainnet via RPC
  2. Verify the token contract exists
  3. Check LP initialization status
  4. Simulate calling get_rewards()
  5. Return pending rewards without executing

No transaction is sent - this is purely a read operation.

Network Verification

The API automatically:

  • Verifies the token exists on Base Mainnet
  • Checks the contract implements required interface
  • Validates LP initialization
  • Returns network information in response

Reward Distribution

50% to Creator (Token Fees)

50% to Platform (ETH Fees)

  • Paid in ETH
  • Sent to factoryCreator address
  • Used to buy and burn $DIGI tokens

Use Cases

Dashboard Monitoring

// Display rewards in real-time dashboard
const updateDashboard = async (tokenAddress) => {
  const rewards = await checkRewards(tokenAddress);
  
  document.getElementById('token-rewards').textContent = 
    `${rewards.pendingRewards.tokenRewards} ${rewards.tokenSymbol}`;
  document.getElementById('eth-rewards').textContent = 
    `${rewards.pendingRewards.ethRewards} ETH`;
};
 
// Update every 30 seconds
setInterval(() => updateDashboard(tokenAddress), 30000);

Alert System

// Alert when rewards exceed threshold
const monitorRewards = async (tokenAddress, threshold) => {
  const rewards = await checkRewards(tokenAddress);
  
  if (parseFloat(rewards.pendingRewards.ethRewards) > threshold) {
    sendAlert(`Rewards exceed ${threshold} ETH! Time to claim.`);
  }
};

Analytics

// Track rewards over time
const trackRewards = async (tokenAddress) => {
  const rewards = await checkRewards(tokenAddress);
  
  // Store in database
  await db.rewards.insert({
    tokenAddress,
    tokenRewards: rewards.pendingRewards.tokenRewards,
    ethRewards: rewards.pendingRewards.ethRewards,
    timestamp: new Date()
  });
};

Best Practices

Polling Frequency

Recommended:

  • High-activity tokens: Every 30 seconds
  • Normal tokens: Every 60 seconds
  • Low-activity tokens: Every 5 minutes

Avoid:

  • Polling more than once every 10 seconds
  • Creating separate requests for same token

Error Handling

const safeCheckRewards = async (tokenAddress) => {
  try {
    return await checkRewards(tokenAddress);
  } catch (error) {
    if (error.response?.status === 400) {
      console.error('Invalid token address');
      return null;
    } else if (error.response?.status === 401) {
      console.error('Invalid API key');
      throw error; // Re-throw auth errors
    } else {
      console.error('Network error, retrying...');
      await new Promise(resolve => setTimeout(resolve, 5000));
      return await checkRewards(tokenAddress);
    }
  }
};

Caching

// Simple cache to avoid redundant requests
const rewardsCache = new Map();
 
const getCachedRewards = async (tokenAddress, maxAge = 30000) => {
  const cached = rewardsCache.get(tokenAddress);
  
  if (cached && Date.now() - cached.timestamp < maxAge) {
    return cached.data;
  }
  
  const data = await checkRewards(tokenAddress);
  rewardsCache.set(tokenAddress, {
    data,
    timestamp: Date.now()
  });
  
  return data;
};

Limitations

  • Network: Base Mainnet only (Chain ID: 8453)
  • Token Types: V4 factory-deployed tokens only
  • Rate Limits: Subject to API rate limits (60 req/min)
  • No gas required: Read-only operation

Troubleshooting

"Invalid token address"

Cause: Token doesn't exist on Base or invalid address format

Solution:

  • Verify token was deployed on Base Mainnet
  • Check address format (0x... 42 characters)
  • Confirm token is deployed via V4 factory

"Invalid contract"

Cause: Contract doesn't implement required interface

Solution:

  • Ensure token was created through Digifi
  • Verify it's a V4 factory token
  • Check you're using the correct address

"LP not yet initialized"

Cause: Liquidity pool hasn't been set up yet

Solution:

  • Wait for deployment to complete
  • Check deployment status
  • Retry after a few minutes

Next Steps


Questions? Contact us at digifievm999@gmail.com