0

I am trying to get the list of all ERC20 token transfers made in a block including contract address, from, to, and value.

The list should be something like this:

{
  blockNumber: 15000000
  contracts: [
    {
      contractAddress: "0xdac17f958d2ee523a2206206994597c13d831ec7",
      transfers: [
        {
          from: "0x2aea2358a1e596380d80e17359acfa0c75f94c9e",
          to: "0x80e17359acfa0c75f94c9e2aea2358a1e596380d",
          value: "0x997fa227"
        }
        ...
      ]
    }
    ...
  ]
}

Is this possible? If so, how?

What I Have Tried

There are many ways to transfer tokens in Ethereum. The simplest way is to use the "transfer" method almost all of the ERC20 contracts include.

If this was the only way, it would have been easy. Simply scan for all transfer method calls for every contract among the transfer list in the block. However, that doesn't work because some contracts have other methods that make token transfers such as "transferFrom". There is no unified way that ERC20 contracts change their balance collection.

If only the same contract had the power to change its balance list, this would be tedious but still possible. However, there are many ways to make token transfers such as calling transfer methods of contracts from other contracts or using decentralized exchanges. Therefore scanning all method calls of a contract fails to capture all token transfers.

What am I missing?

5

0

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.

Browse other questions tagged or ask your own question.