1

Is there a robust way to index historic total supply for all ERC20 tokens?

For tokens that update total supply through mint and burn (with proper events), this is easily done by tallying up mints and subtracting burns.

However, not all tokens, by a longshot, behave that way. I figured a way was to tally up all balances of said token over all addresses (excluding the burn address), but this gets me the 'circulating supply' and not the 'total supply'.

In theory I would be able to get the historic 'total supply' by watching traces/state changes but that's a can of worms I don't want to open.

Any other ways?

2 Answers 2

0

Is there a robust way to index historic total supply for all ERC20 tokens?

Short answer: no.

ERC-20 does not specify events for

  • Newly created tokens
  • Supply changes

To add to the complexity rebase tokens do not emit any events when balances and supplies change, as they have dynamic balances and supplies.

Only way is to either

  • Trace all transactions in the chain and check if they modify totalSupply storage variable. However there is no generic solution, because as mentioned above rebase tokens do not have totalSupply variable as it is a dynamic function.
  • Poll the chain. For historical supplies you need to have an archive node and use eth_call JSON-RPC with a historical block identifier.
0

As you said you can have this information if you use a data source that indexes storage diffs. You can then read the historical values for the _totalSupply storage variable (or similarly named, depending on the token).

One such solution is Token Flow (paid product). It contains full history of decoded storage diffs for Ethereum mainnet in a structured table format.

I have to disclose I work for Token Flow but I'm not aware of any other product that answers the question so it felt right to mention it. If anyone does please feel free to add them as a comment.

2
  • Oh very nice. Is _totalSupply part of the ERC20 spec? As in: do all tokens that implement ERC20 guarantee that _totalSupply is indeed the name of the storage variable?
    – Geert-Jan
    Commented Dec 1, 2023 at 15:50
  • It's not. But it's true for most. We're actually building a metadata table that will include the name of the useful storage slots. Commented Dec 2, 2023 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.