[Ethereum] Is it possible to get the token transfers of a address

etherscan

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.

Best Answer

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