0

Can someone explain to me how to get the amount of tokens that have been transfered from a transaction receipt? I came across some posts that said I can get it out of the data property from the receipt. But how can I turn the data value into a readable amount of tokens? Some others said it can be found in the logs. The transaction itself has a value of 0 on erc20 token transfers, so I need using the receipt is what I understood so far.

Thank you

8
  • 1
    take look at this medium.com/linum-labs/… it uses the ether library with is a light better version of web3js, i will try to find you a simple example with web3js
    – Majd TL
    May 9, 2021 at 7:37
  • 1
    there is also this method web3js.readthedocs.io/en/v1.2.11/web3-eth-abi.html#decodelog from web3 which can be used to decode the logs.
    – Majd TL
    May 9, 2021 at 7:43
  • 1
  • 1
    the transfer transaction in ERC20 token emit an event that tell you from which address to which address and how many tokens. that event can be found in the transaction receipt in the "logs" section. when you get the logs you will get data that need to be decoded like the comments above
    – Majd TL
    May 9, 2021 at 7:46
  • 1
    there is a difference between the value in the tx and the value in the logs, the value in the transaction is the value of transfered ether which is almost always 0 when you transfer tokens. The value in the logs is the amount of transfer tokens
    – Majd TL
    May 9, 2021 at 7:48

0

Browse other questions tagged or ask your own question.