Finding number of tokens in circulation

Iā€™m using ā€œGet ERC20 token metadata by contractā€ (https://docs.moralis.io/web3-data-api/evm/reference/get-token-metadata) to determine the total supply of a token on bsc testnet.
The result I get is below, but is incorrect. It reports total supply as 0.95, when in reality https://testnet.bscscan.com/token/0xA78fd05272f1Bf2A4a365cde5b952D1C0969661d reports 2,074,860.762

Iā€™m a bit of a newbie, so please forgive me if Iā€™m interpreting stuff incorrectly. And if this is not the appropriate API to get the total supply Iā€™d appreciate if you could point me in right direction.

Many thanks
SteveS

[
{
ā€œaddressā€: ā€œ0xa78fd05272f1bf2a4a365cde5b952d1c0969661dā€,
ā€œaddress_labelā€: null,
ā€œnameā€: ā€œHedgeā€,
ā€œsymbolā€: ā€œHDEā€,
ā€œdecimalsā€: ā€œ18ā€,
ā€œlogoā€: null,
ā€œlogo_hashā€: null,
ā€œthumbnailā€: null,
ā€œtotal_supplyā€: ā€œ950000000000000000ā€,
ā€œtotal_supply_formattedā€: ā€œ0.95ā€,
ā€œblock_numberā€: ā€œ0ā€,
ā€œvalidatedā€: 1,
ā€œcreated_atā€: ā€œ2024-04-26T05:54:08.000Zā€,
ā€œpossible_spamā€: false,
ā€œverified_contractā€: false,
ā€œcategoriesā€: [],
ā€œlinksā€: {}
}
]

I have found an alternate method to do this for the bsc testnet (curl command for windows)

curl -X POST -H ā€œContent-Type: application/jsonā€ --data ā€œ{ā€œjsonrpcā€: ā€œ2.0ā€, ā€œmethodā€: ā€œeth_callā€, ā€œparamsā€: [{ā€œtoā€: ā€œ0xA78fd05272f1Bf2A4a365cde5b952D1C0969661dā€, ā€œdataā€: ā€œ0x18160dddā€}, ā€œlatestā€], ā€œidā€: 1}ā€ https://data-seed-prebsc-1-s1.binance.org:8545

and Iā€™m now looking for a method to do this on Sepolia

Any thoughts welcome please
SteveS

Hi @SteveS

It looks like you are directly using the eth_call RPC node method to get read the data from the contract. So to get the data from sepolia you have to update the node url to sepolia node. This change should get the data from sepolia chain.

Thank you for your reply. I have two further questions please.

  1. I cant seem to find a node url for Sepolia - could you help with this please.
  2. It is still not clear to me why the Moralis metadata api seems to return the wrong information. For example, on bsc testnet it gives slightly different numbers for total supply of USDC than bsc scanner. But for the token Iā€™m interested in the result is several orders of magnitude out

Hi @SteveS

  1. When creating node in https://admin.moralis.io/nodes page you can select sepolia under the network tab.

  2. Can you please share the endpoint name and token address where it returns wrong info? We will have a look at it