

To speed up searching it's best if you limit your search to blocks that happened when the contract was deployed or later. Why exactly this string is a bit out of scope for this, but you can read more about events and topics here in the Solidity Docs and in this tutorial that shows how this magic string is done. The magic string here is 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef so you filter all the logs by this topic. When you search for logs, you don't want all the logs, you only want the Transmit logs. You search for logs by using the eth_getlogs RPC function. Since I don't currently run an Ethereum node, I connected to a node from Infura. You can search for all the Transmit events through the JSON RPC interface of any Ethereum node that you have access to. Go to Etherscan Tokens page and search for your token, mine was this one so my address is 0x83e2be8d114f9661221384b3a50d24b96a5653f5.Ī short lesson in Ethereum: every ERC20 compatible token should emit a Transmit event (also called a log) whenever this token is sent from one address to another ( example). Get all the Transfer events from your contract.įor that you need your contract address. To get the list of token holders, you will do: 1. My approach gets you the exact same result as Etherescan's token holders page. Then I will present my opinionated solution in Python that connects to Infura and explain how it works. This applies to any language so you can recreate this on your own if you don't use Python. I will first explain the steps that you need to do to get the list of token holders. Wr.writerow(map(str, "Rank Address Quantity Percentage".split())) Table = getData(sess, str(int(page))).find('table')ĭata = for row in table.find_all('tr')] Return BeautifulSoup(sess.get(url).text, 'html.parser') (There's an example contract address currently hard-coded into it.) #!/usr/bin/env python You can poke around with it to suit your needs. Here's a slightly more complicated script (that I wrote a while ago) that lists all addresses and balances - in rank order - associated with a given token contract, across multiple Etherscan pages. I would like to do this for other ERC20 tokens as well. This would then allow them to manipulate and present it in any way they like. Probably by parsing the state data and creating their own internal representation of it. Im curious how etherscan accomplished this.

# not worried about but which contains special # The page contains another table that we're Wr.writerow(map(str, "Rank Address Balance Percentage TxCount".split())) Wr = csv.writer(f, quoting=csv.QUOTE_ALL) Soup = BeautifulSoup(sess.get(URL).text, 'html.parser')
#ERC20 TOKENS LIST CODE#
Here's some fairly dumb Python code that scrapes that page and writes it to a. If not does anyone know of a way to accomplish this? I don't know of any APIs that will achieve what you want.
