1

I'm trying to get transaction data from etherscan and would like to get exactly what is represented in the "Transaction Action" section of the transaction details.

For example, in this transaction (transaction hash: 0x62f4c14dabbd54bba3657780fffcf258cb358bbb5a8beb7e4eddc9e05b963844) you can see that 1,587.116348149284787459 BBANK was swapped for 0.076451012303912703 ether, which was then swapped for 15,298.900710437101191036 PAD. How is this information parsed from the logs? I've seen many posts asking similar questions but have not seen an answer that explains exactly how this information is pulled.

Looking at the logs, I can see the contract addresses for the various tokens involved in the transaction. But I'm not understanding how the data in the logs gets converted to this straightforward transaction summary.

I've been primarily using python with Web3 and the etherscan API to fetch and parse the data.

1 Answer 1

2

The logs get converted to human-readable output via ABI. You can construct Contract instances in web3.py and then use event methods to parse the output from raw JSON-RPC data to human-readable data structures.

In this case, you need to parse Swap (Uniswap) and Transfer events (ERC-20). You will find ABI files in the respective repositories of the projects on Github. If only Solidity source code is available then you compile that source code yourself to produce the ABI files.

The raw data itself is available over JSON-RPC on any hosted Ethereum node. Etherscan does not provide this service.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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