0

Context

I want to display user transactions as shown in Polygon scan (with all the details, logs, decoded input field, etc.)

Currently I use Ankr's getTransactionsByAddress to get the transactions for a particular wallet address and then parse it through a complicated routine of,

  1. Check if the transaction is to an EOA, if yes, then return it
  2. If it's to a contract,
    1. Find out if it's to an ERC_20 or ERC_721 or other.
    2. Try to decode the input field using generic ABIs (that I found online and have stored in my codebase)
    3. If the above didn't work, then fetch the contract's ABI from the respective chain's scanner and then decode the input field. This doesn't always work as sometimes the ABI returned by the explorers for a contract doesn't have the method used and a callback is made to another contract and sometimes the ABI is unverified and not available.
    4. If the above didn't work return the raw data.

My questions

Is this the best way to get a wallet's transactions as shown in Polygon scan?

Pre-work and Other Thoughts

  • So Unmarshal and DeBank provide APIs that send you all the details that are needed to show wallet transactions in Polygon scan format, but they only return data for a particular chain! I don't want to make too many API calls (one for each chain). Let's just say I want to stick to using Ankr

I checked out related questions, but they are exactly not along the lines of "if what I did is the best way"

0

Your Answer

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