Web3

How to Get the Full Supply of a Token 

Are you on the lookout for the easiest method to get the full provide of a token? If that’s the case, you’re in the proper place. This information will present you ways to effortlessly entry the full provide of a token utilizing Moralis – the {industry}’s main Web3 knowledge supplier. At Moralis, we now have enriched our ERC-20 endpoints with in-depth metadata, guaranteeing you mechanically obtain the full provide of a coin when querying token balances, metadata, and extra. Keen to soar straight into the code? Right here’s an instance displaying our token metadata endpoint in motion:

import fetch from 'node-fetch';

const choices = {
  methodology: 'GET',
  headers: {
    settle for: 'software/json',
    'X-API-Key': 'YOUR_API_KEY'
  },
};

fetch(' choices)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

By calling the endpoint above, you’ll obtain the metadata of the specified token, together with two central parameters: total_supply and total_supply_formatted. Right here’s an instance of what it seems to be like:

[
  {
    address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
    address_label: 'USD Coin (USDC)',
    name: 'USD Coin',
    symbol: 'USDC',
    decimals: '6',
    logo: '
    logo_hash: '442b80bd16af0c0d9b22e03a16753823fe826e5bfd457292b55fa0ba8c1ba213',
    thumbnail: '
    total_supply: '25373535439531383',
    total_supply_formatted: '25373535439.531383',
    fully_diluted_valuation: '25405862477.92',
    block_number: '19888348',
    validated: 1,
    created_at: '2018-08-03T19:28:24.000Z',
    possible_spam: false,
    verified_contract: true,
    categories: [
      'Exchange-Issued Asset Tokens',
      'Platform-Based Utility Tokens',
      'Stablecoins'
    ],
    hyperlinks: {
      //...
    }
  }
]

That’s it! Getting the full provide of a token with Moralis is that straightforward. Should you’d like to study extra about how this works, try our official Token API documentation web page or proceed following alongside on this information.

Additionally, if you need to leverage our APIs, don’t overlook to join with Moralis. You’ll be able to create an account free of cost and acquire on the spot entry to our premier suite of growth instruments!

Overview

In right this moment’s article, we’ll start by clarifying what the complete provide of cryptocurrency means. We’ll additionally delve into the benefits of understanding this metric and talk about widespread use instances the place realizing the complete provide of a token is crucial. After that, we’ll introduce Moralis – the {industry}’s premier Web3 knowledge supplier. In doing so, you’ll learn the way to get hold of the complete provide of a token utilizing Moralis’ Token API by a easy three-step course of:

  1. Get a Moralis API Key



  2. Write a Script Calling the Token Balances with Costs Endpoint



  3. Execute the Code

Following this, we’ll additionally spotlight different Moralis APIs that may be helpful when creating decentralized functions (dapps)! 

So, in case you’re looking for the easiest methodology to get the full provide of a token, this information is for you. Let’s dive in!

What’s the Complete Supply of a Crypto Token? 

The overall provide of a cryptocurrency refers to the quantity of cash or tokens that presently exist. This consists of tokens actively traded or held in circulation, in addition to these locked and awaiting launch to the public market. Primarily, the complete provide is calculated by subtracting the quantity of tokens which were burned or destroyed from the sum of all cash minted!

The overall provide of a cryptocurrency contains two main parts:

  • Circulating Supply: That is the quantity of tokens or cash in circulation. It, as an example, consists of tokens obtainable for buying and selling in the market.

  • Locked Cash: Though they exist, these tokens aren’t accessible for public buying and selling. A venture’s group might retain a portion of the cash in reserve for strategic functions, akin to advertising actions and growth funding, or designate them for particular initiatives like staking rewards.

This overview ought to provide you with a clear understanding of what the complete provide of a cryptocurrency entails. Now, let’s discover some advantages of this explicit metric!

Why Do You Need to Get the Full Supply of a Token?

The overall provide metric of crypto tokens affords a number of advantages, significantly in funding evaluation, financial planning, and market understanding. Listed below are three key examples:

  • Crypto Valuations: The overall provide metric is essential for calculating the valuation of a cryptocurrency. Market capitalization, a central indicator of a coin’s worth, is derived by multiplying the complete provide by the present worth of the asset. This helps traders assess the relative dimension and value of completely different cryptocurrencies.

  • Transparency & Belief: A transparent and immutable document of a token’s complete provide enhances transparency, which is essential for constructing belief amongst traders, customers, regulators, and different stakeholders. Understanding the complete provide ensures all events can confirm the quantity of tokens in circulation.

  • Funding Insights: A coin’s complete provide offers vital insights into its abundance or shortage, that are necessary components for cryptocurrency traders. Shortage can drive demand, whereas abundance might have an effect on the coin’s long-term worth stability.

Token Supply Use Instances 

When it comes to Web3 growth, there are a lot of cases while you want the complete provide of a cryptocurrency. Listed below are three distinguished use instances:

  • Wallets: Cryptocurrency wallets can show the complete provide to present context about a consumer’s holdings. By displaying the complete quantity of tokens obtainable, customers can perceive their share in relation to the whole provide, serving to them make knowledgeable selections about their investments.

  • Decentralized Exchanges (DEXs): DEXs show a token’s complete provide to inform buying and selling selections and supply market context. This metric is essential for merchants because it influences methods, liquidity assessments, and total market evaluation.

  • Analytic Platforms: Platforms that monitor cryptocurrency statistics and market behaviors, akin to Moralis Money, use the complete provide of tokens as a core metric of their reporting. This knowledge helps analysts and traders consider a token’s shortage, distribution, and potential worth.

That offers you an outline of what the complete provide of a token entails, the advantages of this metric, and eventualities by which this knowledge can come in useful. In the following half, we’ll present you the easiest method to get the full provide of a token!

The Best Means to Get the Full Supply of a Token – Introducing Moralis 

The only methodology to entry the full provide of a token is to make the most of a Web3 knowledge supplier akin to Moralis. At Moralis, we offer a complete array of nodes and cross-chain APIs, facilitating the seamless integration of on-chain knowledge into your initiatives. By leveraging our top-tier growth instruments, you’ll be able to create dapps extra swiftly and successfully!

So, how are you going to use Moralis to get the full provide of a token?

Moralis offers extremely complete APIs, delivering extra knowledge with fewer calls. As such, to get the full provide of a token, you solely want to name one of our ERC-20 endpoints, akin to these for balances, metadata, and extra.

To point out you ways this works, let’s take a look at a quick script for fetching the metadata of any ERC-20 token:

import fetch from 'node-fetch';

const choices = {
  methodology: 'GET',
  headers: {
    settle for: 'software/json',
    'X-API-Key': 'YOUR_API_KEY'
  },
};

fetch(' choices)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

By calling the endpoint above, you’ll obtain, amongst different issues, two vital metrics: total_supply and total_supply_formatted. Right here’s an instance of the output:

[
  {
    address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
    address_label: 'USD Coin (USDC)',
    name: 'USD Coin',
    symbol: 'USDC',
    decimals: '6',
    logo: '
    logo_hash: '442b80bd16af0c0d9b22e03a16753823fe826e5bfd457292b55fa0ba8c1ba213',
    thumbnail: '
    total_supply: '25373535439531383',
    total_supply_formatted: '25373535439.531383',
    fully_diluted_valuation: '25405862477.92',
    block_number: '19888348',
    validated: 1,
    created_at: '2018-08-03T19:28:24.000Z',
    possible_spam: false,
    verified_contract: true,
    categories: [
      'Exchange-Issued Asset Tokens',
      'Platform-Based Utility Tokens',
      'Stablecoins'
    ],
    hyperlinks: {
      //...
    }
  }
]

That’s it! Getting the full provide of a token is easy when utilizing Moralis!

Nevertheless, if you need a detailed breakdown of how to name our numerous endpoints, be a part of us in the subsequent part as we stroll you thru a complete tutorial on how to get the full provide of a token!

3-Step Tutorial: How to Get the Full Supply of a Token

Thanks to the complete nature of our API responses, you’ll mechanically get the full provide of a token when calling any Moralis ERC-20 endpoint. To exhibit how this works, we’ll present you ways to fetch the token balances with costs of any handle utilizing our Token API in three easy steps:

  1. Get a Moralis API Key



  2. Write a Script Calling the Token Balances with Costs Endpoint



  3. Run the Code

Nevertheless, earlier than you may get began with the tutorial, you want to take care of a few stipulations!

Stipulations 

For this tutorial, we’ll be utilizing Node.js and JavaScript. As such, in case you haven’t already, ensure you arrange the following earlier than transferring on to the first step:

Guarantee these are put in and prepared to use!

Step 1: Get a Moralis API Key 

To name Moralis’ APIs, you want a Moralis API key. Consequently, the very first thing you want to do is join. You’ll be able to register for a free account by clicking the “Start for Free” button at the prime proper: 

With an account at hand, merely log in and duplicate your Moralis API key:

Be sure you save the key, as you’ll want it in the subsequent part!

Step 2: Write a Script Calling the Token Balances with Costs Endpoint 

Open your IDE, create a folder, and arrange a new venture utilizing the following terminal command:

npm init

Set up the required dependencies by working this command in your terminal:

npm set up node-fetch --save
npm set up moralis @moralisweb3/common-evm-utils

Add "type": "module" to your “package.json” file:

Create a new index.js file and add the following code:

import fetch from 'node-fetch';

const choices = {
  methodology: 'GET',
  headers: {
    settle for: 'software/json',
    'X-API-Key': 'YOUR_API_KEY'
  },
};

fetch(' choices)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Subsequent, you want to configure the code barely. First, exchange YOUR_API_KEY with the key you copied in the earlier step: 

Then, configure the handle parameter to suit your question: 

That’s it for the code. All that is still is to run the script!

Step 3: Run the Code 

Open a new terminal, navigate to the root folder of your venture utilizing the cd command, and run this enter to execute the script:

node index.js

In return, you’ll obtain a response containing not solely the balances of the specified pockets but additionally every token’s full provide, worth, worth change over time, and way more. Right here’s an instance of what it would appear to be:

{
  [
    {
      token_address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
      symbol: 'USDC',
      name: 'USD Coin',
      logo: '
      thumbnail: '
      decimals: 6,
      balance: '1000000000000000',
      possible_spam: false,
      verified_contract: true,
      total_supply: '25373535439531383',
      total_supply_formatted: '25373535439.531383',
      percentage_relative_to_total_supply: 3.941114167488158,
      balance_formatted: '1000000000.0',
      usd_price: 1.0007165741842363,
      usd_price_24hr_percent_change: 0.04563286892779958,
      usd_price_24hr_usd_change: 0.0004564473925958712,
      usd_value: 1000716574.1842363,
      usd_value_24hr_usd_change: 456447.3925958872,
      native_token: false,
      portfolio_percentage: 100
    },
    //...
  ]
}

Included in the response, you’ll discover each the total_supply and total_supply_formatted parameters for every token: 

      //...
      total_supply: '25373535439531383',
      total_supply_formatted: '25373535439.531383',
      //...

That’s it. Leveraging Moralis makes it straightforward to get the full provide of a token! 

Past Token Supply – Diving Deeper Into Moralis’ Web3 APIs 

Moralis is the {industry}’s main Web3 knowledge supplier. Our premier suite of growth instruments consists of nodes for all main chains and specialised APIs tailor-made for numerous use instances. This consists of the Token API, Pockets API, NFT API, Streams API, and plenty of extra. As such, when utilizing Moralis, you’ll be able to construct the whole lot from cryptocurrency wallets to NFT marketplaces with out breaking a sweat!

However what makes our APIs stand out in contrast to the competitors?

  • One Name – All the Knowledge: At Moralis, we offer extremely complete APIs, providing you with extra knowledge with fewer calls. Get all the data you want from each on- and off-chain sources in a single response.

  • Cross-Chain: Streamline your developer expertise with really cross-chain suitable APIs, providing full function parity throughout the largest chains, together with Ethereum, Polygon, BNB Good Chain (BSC), and plenty of extra. With Moralis, you now not want a new knowledge supplier for every chain.

  • Enterprise-Grade Safety: Expertise the gold normal for knowledge safety with Moralis. We’re proud to be the {industry}’s solely SOC 2 Sort 2 licensed Web3 infrastructure supplier, guaranteeing top-tier safety on your initiatives.

This offers you a temporary overview of Moralis. Let’s now dive a bit deeper into our Web3 API suite!

Moralis’ Web3 APIs 

Our suite of APIs consists of over ten use case-specific interfaces, and overlaying all of them on this information can be impractical. As an alternative, we’ll introduce you to three examples:

  • Pockets API: The Pockets API is Web3’s premier interface for pockets knowledge. With this software, you’ll be able to seamlessly fetch a pockets’s historical past, token balances, internet value, profitability, and extra. This makes it the excellent software for constructing wallets, portfolio trackers, and different platforms that require pockets knowledge.

  • NFT API: The NFT API offers the whole lot you want in phrases of NFT knowledge. With this API, you’ll be able to effortlessly get NFT balances, metadata, costs, and extra utilizing simply a few traces of code. Consequently, that is the final software for constructing NFT marketplaces, Web3 video games, and different NFT-related functions.

  • Streams API: Moralis’ Streams API is the ideally suited software for organising Web3 knowledge pipelines. With this industry-leading API, you’ll be able to stream on-chain knowledge into your venture’s backend with simply a few clicks. It’s excellent for organising Web3 alerts, populating databases with real-time knowledge, and way more.

For a complete take a look at all our remaining interfaces, please go to our official Web3 API web page!

Abstract: How to Get the Full Supply of a Token

The simplest and most easy manner to get the full provide of a token is by leveraging a Web3 knowledge supplier like Moralis. At Moralis, we now have enriched our ERC-20 endpoints with detailed metadata. As such, to get the full provide of a token, you merely want to name one of our endpoints for balances, metadata, and so forth. Right here’s an instance utilizing our token metadata endpoint:

import fetch from 'node-fetch';

const choices = {
  methodology: 'GET',
  headers: {
    settle for: 'software/json',
    'X-API-Key': 'YOUR_API_KEY'
  },
};

fetch(' choices)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Once you run the script above, you’ll obtain the metadata of any token, together with the total_supply and total_supply_formatted parameters. Right here’s what the response ought to appear to be:

[
  {
    address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
    address_label: 'USD Coin (USDC)',
    name: 'USD Coin',
    symbol: 'USDC',
    decimals: '6',
    logo: '
    logo_hash: '442b80bd16af0c0d9b22e03a16753823fe826e5bfd457292b55fa0ba8c1ba213',
    thumbnail: '
    total_supply: '25373535439531383',
    total_supply_formatted: '25373535439.531383',
    fully_diluted_valuation: '25405862477.92',
    block_number: '19888348',
    validated: 1,
    created_at: '2018-08-03T19:28:24.000Z',
    possible_spam: false,
    verified_contract: true,
    categories: [
      'Exchange-Issued Asset Tokens',
      'Platform-Based Utility Tokens',
      'Stablecoins'
    ],
    hyperlinks: {
      //...
    }
  }
]

That’s it! Fetching the full provide of a token doesn’t have to be more difficult than this when working with Moralis!

If you would like to get the full provide of a token utilizing our APIs, join with Moralis. You’ll be able to create your account without spending a dime, no bank card required, and acquire on the spot entry to our premier suite of APIs!

DailyBlockchain.News Admin

Our Mission is to bridge the knowledge gap and foster an informed blockchain community by presenting clear, concise, and reliable information every single day. Join us on this exciting journey into the future of finance, technology, and beyond. Whether you’re a blockchain novice or an enthusiast, DailyBlockchain.news is here for you.
Back to top button