⚙️Configuration and Setup

This page will guide you through the configuration and setup process of the TokenSupply app, ensuring a smooth integration with your project. The TokenSupply app is designed to be easily customizable, allowing you to add or modify supported blockchain networks and non-circulating supply addresses as needed.

Prerequisites

Before starting the configuration and setup process, ensure that you have the following installed on your local machine:

  1. Node.js (version 14 or later)

  2. npm or yarn (package manager)

Installation

To begin, clone the TokenSupply app repository or download the source code. Navigate to the root directory of the project and run the following command to install the required dependencies:

npm install

or

yarn

Configuration

The TokenSupply app can be configured by modifying the src/config.ts file. This file contains the necessary settings for interacting with various blockchain networks and fetching token supply data.

Configuring Supported Networks

The chainIdToNetworkMap object in src/config.ts maps chain IDs to their corresponding network information. To add or modify supported networks, update this object with the relevant network information, such as the network's JSON-RPC URL and name:

export const chainIdToNetworkMap: ChainIdToNetwork = {
  "1": {
    jsonRpcUrl: "https://your-json-rpc-url-here",
    name: "Ethereum"
  },
  // ... add or modify other networks as needed
};

Configuring Token Contract Address and API URL

Update the tokenContractAddress and chainId variables in src/config.ts to match the token contract address and chain ID of the token you wish to track:

const tokenContractAddress = "0xa719b8ab7ea7af0ddb4358719a34631bb79d15dc";
const chainId = 56;

Also, ensure that the API_URL variable in src/config.ts is set to the correct API endpoint for fetching token supply data across multiple networks:

const API_URL = 'https://api-leaderboard.dev.svcs.ferrumnetwork.io/api/v1/currencies/token/data';

Configuring Non-Circulating Supply Addresses

The nonCirculatingSupplyAddressesConfig array in src/config.ts holds the configuration for non-circulating supply addresses. To add or modify non-circulating supply addresses, update this array with the relevant address information, such as the name, address, token contract address, JSON-RPC URL, and chain ID:

const nonCirculatingSupplyAddressesConfig: AddressConfiguration[] = [
  {
    Name: "Deployer",
    Address: "0xc2fdcb728170192c72ada2c08957f2e9390076b7",
    TokenContractAddress: "0xe5caef4af8780e59df925470b050fb23c43ca68c",
    JsonRpcUrl: "https://nd-770-685-838.p2pify.com/e30d3ea257d1588823179ce4d5811a61",
    ChainId: "1"
  },
  // ... add or modify other non-circulating supply addresses as needed
];

Running the TokenSupply App

Once you've finished configuring the TokenSupply app, you can start the server by running the following command from the project's root directory:

npm run start

or

yarn start

The server will start listening on the specified port (default is 8080), and you can access the API endpoints via your web browser or by making HTTP requests.

Integrating the TokenSupply App with Your Project

To integrate the TokenSupply app with your project, use the provided API endpoints to fetch token supply data and display it on your website or application.

For example, to display the total supply of tokens across all supported networks, make a request to the /totalSupplyAcrossNetworks endpoint and display the returned data on your site:

fetch('http://localhost:8080/totalSupplyAcrossNetworks')
  .then(response => response.json())
  .then(data => {
    // Display the data on your website
  });

Repeat this process for other endpoints, such as /circulatingSupplyBalance and /nonCirculatingSupplyBalancesByAddress, to display additional token supply information as needed.

By following these steps, you can successfully configure, set up, and integrate the TokenSupply app with your project.

Last updated