You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 19, 2022. It is now read-only.
I am reading this github as I need to do something similar on ethereum, and I have to say this is a wonderful project and helps me a lot. 馃憤
Here I have a question while reading "Reading ERC-20 Token Event Logs" section. There we have code as below:
My question is as this line err := contractAbi.Unpack(&transferEvent, "Transfer", vLog.Data)
already parsed/unpacked the data (from/to fields from message), why we still need to get Hex data from vLog.Topics as below code shows ?
Based on my understanding, Topics stores the message type Hash, we may not get the correct from/to by convert Topics[*].Hex to address, correct me if I am wrong. :)
Thanks!
The text was updated successfully, but these errors were encountered:
@yueawang Thanks! and sorry it's not clear; the topics are indexed event arguments.
There can only be a maximum of 4 topics, the first topic is the event log signature hash.
The other 3 are optional and specified by the contract creator by using the indexed keyword.
Unpack unpacks the log data. The log data contains event arguments that are not indexed.
The log event signature is: event Transfer(address indexed from, address indexed to, uint tokens); and as you can see from and to are indexed while tokens is not.
So from and to are topics[1] and topics[2] respectively
Hi, @miguelmota
I am reading this github as I need to do something similar on ethereum, and I have to say this is a wonderful project and helps me a lot. 馃憤
Here I have a question while reading "Reading ERC-20 Token Event Logs" section. There we have code as below:
My question is as this line
err := contractAbi.Unpack(&transferEvent, "Transfer", vLog.Data)
already parsed/unpacked the data (from/to fields from message), why we still need to get Hex data from vLog.Topics as below code shows ?
Based on my understanding, Topics stores the message type Hash, we may not get the correct from/to by convert Topics[*].Hex to address, correct me if I am wrong. :)
Thanks!
The text was updated successfully, but these errors were encountered: