Search code examples
javascriptblockchainweb3jsethers.js

ERC-20 holders list on Polygon


How do I get a list of a given ERC20 token holders?

I use QuickNode + ethers.js or web3.js and I have SC address for the ERC20 token.

Is there a short way to get a list of token holders or do I have to look through transactions?

I've tried Covalent's endpoint for that, but they are not reliable --> 90% of requests are 504. I need to use a provider that gives me access to multiple chains so polygonscan API doesn't work in my case.


Solution

  • There is no straightforward way to get a list of token holders from the network. However, there are few workarounds:

    1. If you have control over the ERC20 token, you could add a tracking array of token holders that is updated by overriding the transfer function.
    2. If you do not have control over the ERC20 token, you could track all of the ERC20 transfer event logs to build and maintain a ledger of holders.
    3. If you do not have the resources to track every transaction, you could rely on API services such as Ankr Advanced API.