Are you looking for the easiest way to get the full supply of a token? If so, you’re in the right place. This guide will show you how to effortlessly access the full supply of a token using Moralis – the industry’s leading Web3 data provider. At Moralis, we have enriched our ERC-20 endpoints with in-depth metadata, ensuring you automatically receive the full supply of a coin when querying token balances, metadata, and more. Eager to jump straight into the code? Here’s an example showing our token metadata endpoint in action:
import fetch from ‘node-fetch’;
const options = {
method: ‘GET’,
headers: {
accept: ‘application/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};
fetch(‘https://deep-index.moralis.io/api/v2.2/erc20/metadata?chain=eth&addresses%5B0%5D=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48’, options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
By calling the endpoint above, you’ll receive the metadata of the specified token, including two central parameters: total_supply and total_supply_formatted. Here’s an example of what it looks 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’
],
links: {
//…
}
}
]
That’s it! Getting the full supply of a token with Moralis is that simple. If you’d like to learn more about how this works, check out our official Token API documentation page or continue following along in this guide.
Also, if you want to leverage our APIs, don’t forget to sign up with Moralis. You can create an account free of charge and gain instant access to our premier suite of development tools!
Overview
In today’s article, we will begin by clarifying what the total supply of cryptocurrency means. We’ll also delve into the advantages of understanding this metric and discuss common use cases where knowing the total supply of a token is essential. After that, we’ll introduce Moralis – the industry’s premier Web3 data provider. In doing so, you’ll learn how to obtain the total supply of a token using Moralis’ Token API through a simple three-step process:
Get a Moralis API KeyWrite a Script Calling the Token Balances with Prices EndpointExecute the Code
Following this, we’ll also highlight other Moralis APIs that can be useful when developing decentralized applications (dapps)!
So, if you’re seeking the simplest method to get the full supply of a token, this guide is for you. Let’s dive in!
What is the Total Supply of a Crypto Token?
The total supply of a cryptocurrency refers to the number of coins or tokens that currently exist. This includes tokens actively traded or held in circulation, as well as those locked and awaiting release to the public market. Essentially, the total supply is calculated by subtracting the number of tokens that have been burned or destroyed from the sum of all coins minted!
The total supply of a cryptocurrency comprises two primary components:
Circulating Supply: This is the number of tokens or coins in circulation. It, for instance, includes tokens available for trading in the market. Locked Coins: Although they exist, these tokens are not accessible for public trading. A project’s team may retain a portion of the coins in reserve for strategic purposes, such as marketing activities and development funding, or designate them for specific initiatives like staking rewards.
This overview should give you a clear understanding of what the total supply of a cryptocurrency entails. Now, let’s explore some benefits of this particular metric!
Why Do You Want to Get the Full Supply of a Token?
The total supply metric of crypto tokens offers several benefits, particularly in investment analysis, economic planning, and market understanding. Here are three key examples:
Crypto Valuations: The total supply metric is crucial for calculating the valuation of a cryptocurrency. Market capitalization, a central indicator of a coin’s value, is derived by multiplying the total supply by the current price of the asset. This helps investors assess the relative size and worth of different cryptocurrencies. Transparency & Trust: A clear and immutable record of a token’s total supply enhances transparency, which is crucial for building trust among investors, users, regulators, and other stakeholders. Knowing the total supply ensures all parties can verify the number of tokens in circulation. Investment Insights: A coin’s total supply provides critical insights into its abundance or scarcity, which are important factors for cryptocurrency investors. Scarcity can drive demand, while abundance may affect the coin’s long-term price stability.
Token Supply Use Cases
When it comes to Web3 development, there are many instances when you need the total supply of a cryptocurrency. Here are three prominent use cases:
Wallets: Cryptocurrency wallets can display the total supply to provide context about a user’s holdings. By showing the total number of tokens available, users can understand their share in relation to the entire supply, helping them make informed decisions about their investments. Decentralized Exchanges (DEXs): DEXs display a token’s total supply to inform trading decisions and provide market context. This metric is crucial for traders as it influences strategies, liquidity assessments, and overall market analysis. Analytic Platforms: Platforms that track cryptocurrency statistics and market behaviors, such as Moralis Money, use the total supply of tokens as a core metric in their reporting. This data helps analysts and investors evaluate a token’s scarcity, distribution, and potential value.
That gives you an overview of what the total supply of a token entails, the benefits of this metric, and scenarios in which this data can come in handy. In the following part, we’ll show you the easiest way to get the full supply of a token!
The Easiest Way to Get the Full Supply of a Token – Introducing Moralis
The simplest method to access the full supply of a token is to utilize a Web3 data provider such as Moralis. At Moralis, we provide a comprehensive array of nodes and cross-chain APIs, facilitating the seamless integration of on-chain data into your projects. By leveraging our top-tier development tools, you can create dapps more swiftly and effectively!
So, how can you use Moralis to get the full supply of a token?
Moralis provides highly comprehensive APIs, delivering more data with fewer calls. As such, to get the full supply of a token, you only need to call one of our ERC-20 endpoints, such as those for balances, metadata, and more.
To show you how this works, let’s look at a short script for fetching the metadata of any ERC-20 token:
import fetch from ‘node-fetch’;
const options = {
method: ‘GET’,
headers: {
accept: ‘application/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};
fetch(‘https://deep-index.moralis.io/api/v2.2/erc20/metadata?chain=eth&addresses%5B0%5D=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48’, options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
By calling the endpoint above, you’ll receive, among other things, two critical metrics: total_supply and total_supply_formatted. Here’s an example 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’
],
links: {
//…
}
}
]
That’s it! Getting the full supply of a token is straightforward when using Moralis!
However, if you want a detailed breakdown of how to call our various endpoints, join us in the next section as we walk you through a comprehensive tutorial on how to get the full supply of a token!
3-Step Tutorial: How to Get the Full Supply of a Token
Thanks to the comprehensive nature of our API responses, you’ll automatically get the full supply of a token when calling any Moralis ERC-20 endpoint. To demonstrate how this works, we’ll show you how to fetch the token balances with prices of any address using our Token API in three simple steps:
Get a Moralis API KeyWrite a Script Calling the Token Balances with Prices EndpointRun the Code
However, before you can get started with the tutorial, you need to deal with a few prerequisites!
Prerequisites
For this tutorial, we’ll be using Node.js and JavaScript. As such, if you haven’t already, make sure you set up the following before moving on to the first step:
Ensure these are installed and ready to use!
Step 1: Get a Moralis API Key
To call Moralis’ APIs, you need a Moralis API key. Consequently, the first thing you need to do is sign up. You can register for a free account by clicking the “Start for Free” button at the top right:
With an account at hand, simply log in and copy your Moralis API key:
Make sure you save the key, as you’ll need it in the next section!
Step 2: Write a Script Calling the Token Balances with Prices Endpoint
Open your IDE, create a folder, and set up a new project using the following terminal command:
npm init
Install the required dependencies by running this command in your terminal:
npm install node-fetch –save
npm install 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 options = {
method: ‘GET’,
headers: {
accept: ‘application/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};
fetch(‘https://deep-index.moralis.io/api/v2.2/wallets/0x4B16c5dE96EB2117bBE5fd171E4d203624B014aa/tokens?chain=eth’, options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
Next, you need to configure the code slightly. First, replace YOUR_API_KEY with the key you copied in the previous step:
Then, configure the address parameter to fit your query:
That’s it for the code. All that remains is to run the script!
Step 3: Run the Code
Open a new terminal, navigate to the root folder of your project using the cd command, and run this input to execute the script:
node index.js
In return, you’ll receive a response containing not only the balances of the specified wallet but also each token’s full supply, price, price change over time, and much more. Here’s an example of what it might look like:
{
[
{
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 in the response, you’ll find both the total_supply and total_supply_formatted parameters for each token:
//…
total_supply: ‘25373535439531383’,
total_supply_formatted: ‘25373535439.531383’,
//…
That’s it. Leveraging Moralis makes it easy to get the full supply of a token!
Beyond Token Supply – Diving Deeper Into Moralis’ Web3 APIs
Moralis is the industry’s leading Web3 data provider. Our premier suite of development tools includes nodes for all major chains and specialized APIs tailored for various use cases. This includes the Token API, Wallet API, NFT API, Streams API, and many more. As such, when using Moralis, you can build everything from cryptocurrency wallets to NFT marketplaces without breaking a sweat!
But what makes our APIs stand out compared to the competition?
One Call – All the Data: At Moralis, we provide highly comprehensive APIs, giving you more data with fewer calls. Get all the information you need from both on- and off-chain sources in a single response. Cross-Chain: Streamline your developer experience with truly cross-chain compatible APIs, offering full feature parity across the biggest chains, including Ethereum, Polygon, BNB Smart Chain (BSC), and many more. With Moralis, you no longer need a new data provider for each chain. Enterprise-Grade Security: Experience the gold standard for data security with Moralis. We are proud to be the industry’s only SOC 2 Type 2 certified Web3 infrastructure provider, ensuring top-tier security for your projects.
This gives you a brief overview of Moralis. Let’s now dive a bit deeper into our Web3 API suite!
Moralis’ Web3 APIs
Our suite of APIs includes over ten use case-specific interfaces, and covering all of them in this guide would be impractical. Instead, we’ll introduce you to three examples:
Wallet API: The Wallet API is Web3’s premier interface for wallet data. With this tool, you can seamlessly fetch a wallet’s history, token balances, net worth, profitability, and more. This makes it the perfect tool for building wallets, portfolio trackers, and other platforms that require wallet data.
NFT API: The NFT API provides everything you need in terms of NFT data. With this API, you can effortlessly get NFT balances, metadata, prices, and more using just a few lines of code. Consequently, this is the ultimate tool for building NFT marketplaces, Web3 games, and other NFT-related applications.
Streams API: Moralis’ Streams API is the ideal tool for setting up Web3 data pipelines. With this industry-leading API, you can stream on-chain data into your project’s backend with just a few clicks. It’s perfect for setting up Web3 alerts, populating databases with real-time data, and much more.
For a comprehensive look at all our remaining interfaces, please visit our official Web3 API page!
Summary: How to Get the Full Supply of a Token
The easiest and most straightforward way to get the full supply of a token is by leveraging a Web3 data provider like Moralis. At Moralis, we have enriched our ERC-20 endpoints with detailed metadata. As such, to get the full supply of a token, you simply need to call one of our endpoints for balances, metadata, etc. Here’s an example using our token metadata endpoint:
import fetch from ‘node-fetch’;
const options = {
method: ‘GET’,
headers: {
accept: ‘application/json’,
‘X-API-Key’: ‘YOUR_API_KEY’
},
};
fetch(‘https://deep-index.moralis.io/api/v2.2/erc20/metadata?chain=eth&addresses%5B0%5D=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48’, options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
When you run the script above, you’ll receive the metadata of any token, including the total_supply and total_supply_formatted parameters. Here’s what the response should look 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’
],
links: {
//…
}
}
]
That’s it! Fetching the full supply of a token doesn’t have to be more challenging than this when working with Moralis!
If you want to get the full supply of a token using our APIs, sign up with Moralis. You can create your account for free, no credit card required, and gain instant access to our premier suite of APIs!