I'm trying to find how etherscan finds the "Tokens Transferred" using the logs of a given transaction. Using this
0x52caaf79bf913064a70a6c9d917fd4190cdb099fe79e7d3a9dfe0600e1cfbc81 arbitrary transaction as an example.
I used the below code (web3.py) to find the logs in the transaction receipt:
from web3 import Web3 provider = Web3.HTTPProvider('https://mainnet.infura.io/v3/XXXXXXXXXXXXX') w3 = Web3(provider) receipt= w3.eth.getTransactionReceipt('0x52caaf79bf913064a70a6c9d917fd4190cdb099fe79e7d3a9dfe0600e1cfbc81')
receipt["logs"] generates the logs which can be found in Etherscan under "event logs". However, only 3 log indices result in the tokens transferred section (logs 156, 158 and 162).
Can someone help me understand how does etherscan knows that only these should appear in the picture seen above, from amongst all the logs?