1

I'm trying to pull up a list of all incoming transfers to an ETH address. The research I've done seems to indicate this can be done via etherscan using the logs module. (https://docs.etherscan.io/api-endpoints/logs).

However I do not know how to produce the parameters the API requires.

As an example, say I want to list all MATIC transfers to an address.

The MATIC contract address is 0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0 The destination address is 0xBcef3db86DCcDa6CA1fdBba91Abd525c8D3BF363

How do I take this information and produce the topic_0 and topic_1 parameters for the API request?

Thanks, Peter

1
  • You might want to take a look at a data indexing solution such as The Graph. Commented Oct 30, 2022 at 11:46

4 Answers 4

2

Ok, after some research. topic_0 is the hash of the event signature. I used https://emn178.github.io/online-tools/keccak_256.html to generate the hash.

In this case the event I want is Transfer(address,address,uint256) and the hash is ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

topic_1 is the 1st parameter of the method, which is the from address. I don't want to specify this. Instead I want to specify the to address which is topic_2. topic_2 must be 66 chars, so I padded the destination address with zeros. So topic_2=0x000000000000000000000000Bcef3db86DCcDa6CA1fdBba91Abd525c8D3BF363

This gives me a list of all ERC20 tokens transferred to the destination address. Now I need to figure out how to tell what token and how many were transferred for each record.

0

Unless I'm misunderstanding, this should be pretty easy to do using the ERC-20 transfers API endpoint (https://docs.etherscan.io/api-endpoints/accounts#get-a-list-of-erc20-token-transfer-events-by-address).

For your above query, I'd do:

https://api.etherscan.io/api?module=account&action=tokentx&contractaddress=0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0&address=0xBcef3db86DCcDa6CA1fdBba91Abd525c8D3BF363&page=1&offset=10000&startblock=0&endblock=99999999&sort=asc&apikey=[INSERT API KEY HERE]

This will list out all transfers of the MATIC token to or from that address (and it's then trivially easy to filter out all the from transactions if you want to, so you only get the incoming transactions to this address).

0

Moralis provide such API. Give it just the chain and the wallet, and your good to go.

https://docs.moralis.io/web3-data-api/evm/reference/get-wallet-token-transfers

0

If it's on ethereum mainnet, you could use a service like Dune or Google Big Query to get all transaction/token transfers to addresses. The lag time for data ranges but no greater than 10 minutes.

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.