7

I would like to obtain token transfer data from an address via Rest API

For example, take this address: https://etherscan.io/address/0xfbb1b73c4f0bda4f67dca266ce6ef42f520fbb98#tokentxns

(Etherscan doesn't answer support questions about their API "because its free and presented as is", and they don't seem to have an API endpoint to show that same data.)

That link shows all of the token transfers for that address.

I would like to see all token transfers of X for that address. X being a token of my choice.

What is involved with obtaining that data via API?

1 Answer 1

11

How about using Etherscan's Event Log API?

https://api.etherscan.io/api?module=logs&action=getLogs
    &fromBlock=0
    &toBlock=latest
    &address=[Token Contract Address]
    &topic0=0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
    &topic1=[From Address, padded to 32 bytes - optional]
    &topic2=[To Address, padded to 32 bytes - optional]

In the above topic0 is the signature of an ERC20 Transfer event.

For example, the following link shows you all the send transactions of LLL tokens from my account (two transactions).

Here, your X (the token) is represented by the token's contract address, which is easy enough to find out for the various tokens.

As always, the API will return you a maximum of 10000 results, so you may need to manage fromBlock and toBlock accordingly.

10
  • this is insightful, why do I get the same API response whether topic1 is there or not, in your example. I would also like to know amounts of the transfer, I'm guessing this will be multiple calls
    – CQM
    Commented Aug 19, 2017 at 19:51
  • "why do I get the same API response whether topic1 is there or not, in your example." - because I'm the only person who has yet sent any of these tokens. Sorry, bad example :-) " I would also like to know amounts of the transfer," - this is the data field of the JSON response; no multiple call needed. Commented Aug 19, 2017 at 20:12
  • Okay, so its a hex to decimal conversion in the data field. How do I know where the decimal is for a divisible contract unit?
    – CQM
    Commented Aug 22, 2017 at 9:17
  • 2
    @benjaminion how to get the signature for specified event and how to decode the data: 0x0000000000000000000000000000000000000000000000000000000000000032 Commented Sep 11, 2017 at 8:47
  • 3
    @EnZo - The signature of an ERC20 Transfer event is keccak256("Transfer(address,address,uint256)") = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. This format is part of the Ethereum ABI specification (see topics[0]). Commented Jan 15, 2018 at 14:43

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.