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