Get the Full Provide of a Token  – Moralis Web3


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

import fetch from 'node-fetch';

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

fetch('https://deep-index.moralis.io/api/v2.2/erc20/metadata?chain=eth&addressespercent5B0percent5D=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 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 required token, together with two central parameters: total_supply and total_supply_formatted. Right here’s an instance of what it appears like:

[
  {
    address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
    address_label: 'USD Coin (USDC)',
    name: 'USD Coin',
    symbol: 'USDC',
    decimals: '6',
    logo: 'https://logo.moralis.io/0x1_0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_e6ec22e3ef954a7f9eda04f294938f4d',
    logo_hash: '442b80bd16af0c0d9b22e03a16753823fe826e5bfd457292b55fa0ba8c1ba213',
    thumbnail: 'https://logo.moralis.io/0x1_0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_e6ec22e3ef954a7f9eda04f294938f4d',
    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 complete provide of a token with Moralis is that straightforward. If you happen to’d prefer to be taught extra about how this works, try our official Token API documentation web page or proceed following alongside on this information.

Additionally, if you wish to leverage our APIs, don’t neglect to enroll with Moralis. You may create an account freed from cost and acquire immediate entry to our premier suite of growth instruments!

Overview

In right this moment’s article, we are going to start by clarifying what the full provide of cryptocurrency means. We’ll additionally delve into some great benefits of understanding this metric and focus on frequent use instances the place understanding the full provide of a token is crucial. After that, we’ll introduce Moralis – the {industry}’s premier Web3 knowledge supplier. In doing so, you’ll discover ways to acquire the full provide of a token utilizing Moralis’ Token API by means of 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 purposes (dapps)! 

So, for those who’re searching for the only technique to get the complete provide of a token, this information is for you. Let’s dive in!

What’s the Complete Provide of a Crypto Token? 

The entire provide of a cryptocurrency refers back to the variety of cash or tokens that presently exist. This contains tokens actively traded or held in circulation, in addition to these locked and awaiting launch to the general public market. Basically, the full provide is calculated by subtracting the variety of tokens which were burned or destroyed from the sum of all cash minted!

The entire provide of a cryptocurrency contains two major elements:

  • Circulating Provide: That is the variety of tokens or cash in circulation. It, as an illustration, contains tokens accessible for buying and selling out there.
  • Locked Cash: Though they exist, these tokens usually are not accessible for public buying and selling. A challenge’s group could retain a portion of the cash in reserve for strategic functions, corresponding to advertising and marketing actions and growth funding, or designate them for particular initiatives like staking rewards.

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

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

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

  • Crypto Valuations: The entire 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 full provide by the present value of the asset. This helps traders assess the relative measurement and price of various cryptocurrencies.
  • Transparency & Belief: A transparent and immutable report of a token’s whole provide enhances transparency, which is essential for constructing belief amongst traders, customers, regulators, and different stakeholders. Understanding the full provide ensures all events can confirm the variety of tokens in circulation.
  • Funding Insights: A coin’s whole provide supplies essential insights into its abundance or shortage, that are essential elements for cryptocurrency traders. Shortage can drive demand, whereas abundance could have an effect on the coin’s long-term value stability.

Token Provide Use Circumstances 

Relating to Web3 growth, there are lots of cases while you want the full provide of a cryptocurrency. Listed here are three outstanding use instances:

  • Wallets: Cryptocurrency wallets can show the full provide to offer context a couple of consumer’s holdings. By exhibiting the full variety of tokens accessible, customers can perceive their share in relation to the complete provide, serving to them make knowledgeable choices about their investments.
  • Decentralized Exchanges (DEXs): DEXs show a token’s whole provide to tell buying and selling choices and supply market context. This metric is essential for merchants because it influences methods, liquidity assessments, and total market evaluation.
  • Analytic Platforms: Platforms that observe cryptocurrency statistics and market behaviors, corresponding to Moralis Cash, use the full 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 full provide of a token entails, the advantages of this metric, and eventualities during which this knowledge can turn out to be useful. Within the following half, we’ll present you the simplest method to get the complete provide of a token!

The Best Solution to Get the Full Provide of a Token – Introducing Moralis 

The only technique to entry the complete provide of a token is to make the most of a Web3 knowledge supplier corresponding 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 complete provide of a token?

Moralis supplies extremely complete APIs, delivering extra knowledge with fewer calls. As such, to get the complete provide of a token, you solely must name one in all our ERC-20 endpoints, corresponding to these for balances, metadata, and extra.

To indicate you the way this works, let’s have a look at a brief script for fetching the metadata of any ERC-20 token:

import fetch from 'node-fetch';

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

fetch('https://deep-index.moralis.io/api/v2.2/erc20/metadata?chain=eth&addressespercent5B0percent5D=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 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 essential 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: 'https://logo.moralis.io/0x1_0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_e6ec22e3ef954a7f9eda04f294938f4d',
    logo_hash: '442b80bd16af0c0d9b22e03a16753823fe826e5bfd457292b55fa0ba8c1ba213',
    thumbnail: 'https://logo.moralis.io/0x1_0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_e6ec22e3ef954a7f9eda04f294938f4d',
    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 complete provide of a token is easy when utilizing Moralis!

Nevertheless, if you’d like an in depth breakdown of learn how to name our numerous endpoints, be a part of us within the subsequent part as we stroll you thru a complete tutorial on learn how to get the complete provide of a token!

3-Step Tutorial: Get the Full Provide of a Token

Due to the great nature of our API responses, you’ll mechanically get the complete provide of a token when calling any Moralis ERC-20 endpoint. To display how this works, we’ll present you learn how 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, it is advisable to cope with a number of stipulations!

Stipulations 

For this tutorial, we’ll be utilizing Node.js and JavaScript. As such, for those who haven’t already, ensure you arrange the next earlier than transferring on to step one:

Guarantee these are put in and able to use!

Step 1: Get a Moralis API Key 

To name Moralis’ APIs, you want a Moralis API key. Consequently, the very first thing it is advisable to do is join. You may register for a free account by clicking the “Begin for Free” button on the high proper: 

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

Be sure you save the important thing, as you’ll want it within the subsequent part!

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

Open your IDE, create a folder, and arrange a brand new challenge utilizing the next 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 "sort": "module" to your “package deal.json” file:

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

import fetch from 'node-fetch';

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

fetch('https://deep-index.moralis.io/api/v2.2/wallets/0x4B16c5dE96EB2117bBE5fd171E4d203624B014aa/tokens?chain=eth', choices)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));

Subsequent, it is advisable to configure the code barely. First, substitute YOUR_API_KEY with the important thing you copied within 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 brand new terminal, navigate to the foundation folder of your challenge 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 required pockets but in addition every token’s full provide, value, value change over time, and rather more. Right here’s an instance of what it’d appear to be:

{
  [
    {
      token_address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
      symbol: 'USDC',
      name: 'USD Coin',
      logo: 'https://logo.moralis.io/0x1_0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_e6ec22e3ef954a7f9eda04f294938f4d',
      thumbnail: 'https://logo.moralis.io/0x1_0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_e6ec22e3ef954a7f9eda04f294938f4d',
      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 within 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 simple to get the complete provide of a token! 

Past Token Provide – Diving Deeper Into Moralis’ Web3 APIs 

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

However what makes our APIs stand out in comparison with the competitors?

  • One Name – All of the Knowledge: At Moralis, we offer extremely complete APIs, supplying 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 actually cross-chain appropriate APIs, providing full function parity throughout the largest chains, together with Ethereum, Polygon, BNB Sensible Chain (BSC), and plenty of extra. With Moralis, you not want a brand 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 Kind 2 licensed Web3 infrastructure supplier, guaranteeing top-tier safety to your initiatives.

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

Moralis’ Web3 APIs 

Our suite of APIs contains over ten use case-specific interfaces, and protecting all of them on this information can be impractical. As a substitute, we’ll introduce you to 3 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 price, profitability, and extra. This makes it the proper software for constructing wallets, portfolio trackers, and different platforms that require pockets knowledge.
  • NFT API: The NFT API supplies all the pieces you want by way of NFT knowledge. With this API, you’ll be able to effortlessly get NFT balances, metadata, costs, and extra utilizing only a few strains of code. Consequently, that is the last word software for constructing NFT marketplaces, Web3 video games, and different NFT-related purposes.
  • Streams API: Moralis’ Streams API is the best software for organising Web3 knowledge pipelines. With this industry-leading API, you’ll be able to stream on-chain knowledge into your challenge’s backend with only a few clicks. It’s excellent for organising Web3 alerts, populating databases with real-time knowledge, and rather more.

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

Abstract: Get the Full Provide of a Token

The best and most simple method to get the complete provide of a token is by leveraging a Web3 knowledge supplier like Moralis. At Moralis, we have now enriched our ERC-20 endpoints with detailed metadata. As such, to get the complete provide of a token, you merely must name one in all our endpoints for balances, metadata, and many others. Right here’s an instance utilizing our token metadata endpoint:

import fetch from 'node-fetch';

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

fetch('https://deep-index.moralis.io/api/v2.2/erc20/metadata?chain=eth&addressespercent5B0percent5D=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 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: 'https://logo.moralis.io/0x1_0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_e6ec22e3ef954a7f9eda04f294938f4d',
    logo_hash: '442b80bd16af0c0d9b22e03a16753823fe826e5bfd457292b55fa0ba8c1ba213',
    thumbnail: 'https://logo.moralis.io/0x1_0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48_e6ec22e3ef954a7f9eda04f294938f4d',
    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 complete provide of a token doesn’t should be tougher than this when working with Moralis!

If you wish to get the complete provide of a token utilizing our APIs, join with Moralis. You may create your account without spending a dime, no bank card required, and acquire immediate entry to our premier suite of APIs!



Source link

- Advertisement - spot_img

Latest stories

You might also like...