1

I want to get token transfers of an address (incoming) but i guess once i have this sorted i can figure that out.

So for example here - https://etherscan.io/address/0x3f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be#tokentxns

They have all the token transfers and i can't really see in their API to get all the token transfers so i was wondering if anyone knew how to do to get all token transfers going on the address. I have tried doing many stuff while trying to using web3.js and try subscribe to events. I realise when a smart contract transfers a token the Transfer event is called and emitted but i don't see how to show all the token transfers using etherscan API. Thanks guys.

0

If you wish to use etherscan API, you can use https://etherscan.io/apis#logs.

However, you'll have to know contract addresses of all tokens that you wish to watch.

The Transfer event for ERC20 is defined as

event Transfer(address indexed _from, address indexed _to, uint256 _value);

That means:

  • topic0 will be the hash of the signature of the event itself
  • topic1 will be the address of the sender
  • topic2 will be the address of the receiver

For orientation, you can look into the logs in the transaction receipt of a transfer transaction. -> e.g. https://etherscan.io/tx/0x5c354e4f25f2da8ee608c445cad43c171bc553859dd787fc0800a904344a7ecd#eventlog

  • How does etherscan do it though? I want to get all token transfers..? and i don't know all the contract addresses ;/ – David Honkins Mar 27 '18 at 12:54
  • They have the complete chain. Most probably also with indexed data in their own database. This way it's easy to compile a list of all ERC20 contract instances. If you wish that too, you'll have to setup own node, make a full sync and parse through the transactions and transaction receipts (which include the logs). – ivicaa Mar 27 '18 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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