📐TokenSupply App Architecture

The TokenSupply app is designed to provide a reliable and efficient way of fetching token supply data across multiple blockchain networks. The architecture of the app ensures modularity, scalability, and ease of integration with other projects and applications. This page will give you an overview of the TokenSupply app's architecture and its components.

Overview

The TokenSupply app is built using TypeScript and is organized into a modular structure that separates concerns and makes the code easy to understand and maintain. The app consists of the following main components:

  1. Configuration: Configuration files that store API endpoints, token contract addresses, and other app settings.

  2. Server: An Express.js server that handles incoming HTTP requests and serves as the API for the app.

  3. Token Supply Calculation: A set of functions and services that interact with blockchain networks to fetch token supply data.

  4. Utilities: Utility functions that facilitate data processing and API interaction.

Components

Configuration

The config.ts file stores the app's configuration data, such as API endpoints for different blockchain networks, token contract addresses, and other relevant settings. It also exports utility functions that fetch and process this configuration data for use within the app.

Server

The server.ts file sets up an Express.js server that listens for incoming HTTP requests and serves as the API for the TokenSupply app. The server exposes multiple endpoints to fetch token supply data, non-circulating supply balances, and other information. It also handles error handling and response formatting.

Token Supply Calculation

The getSupplyAcrossNetworks.ts file contains the core logic for fetching token supply data across multiple blockchain networks. It exports functions that interact with blockchain networks and smart contracts to fetch and calculate various token supply metrics. These functions include:

  1. getTotalSupplyAcrossNetworks: This function fetches the total token supply across all supported networks by interacting with the token contract on each network.

  2. getNonCirculatingSupplyBalances: This function calculates the non-circulating supply of tokens by fetching the token balances of specific addresses on different networks. These addresses typically include the deployer, treasury, and bridge pool addresses.

Utilities

The TokenSupply app includes utility functions that are used throughout the app to facilitate data processing and API interaction. Some of these utilities are:

  1. getWeb3Instance: A utility function that creates a new Web3 instance for a given JSON-RPC URL, allowing the app to interact with different blockchain networks.

  2. fetchTokenSupply: A utility function that fetches the token supply for a specific token contract address on a given network using the Web3 instance.

  3. fetchTokenBalance: A utility function that fetches the token balance for a specific address on a given network using the Web3 instance.

  4. formatTokenBalance: A utility function that formats token balance data for display or further processing.

By using this modular architecture, the TokenSupply app can easily be integrated with other projects or applications. Developers can use the provided API endpoints or import and utilize the token supply calculation functions directly in their projects. The app's architecture also allows for easy extension and addition of new features or support for additional blockchain networks in the future.

Last updated