I have events like this in my .sol file
event userActivated(address owner, address contractAddr);
event userDeactivated(address owner, address contractAddr);
And I am using ethclient Go module to parse events. here is the code
func listEvents() string{
var tempEvents Event
client, err := ethclient.Dial(RpcPath)
if err!=nil{
glog.Fatal("Client error",err)
}
query := ethereum.FilterQuery{
FromBlock: nil,
ToBlock: nil,
Addresses: []common.Address{},
}
logs, err := client.FilterLogs(context.Background(), query)
if err != nil {
glog.Fatal(err)
}
//get ABI for parsing data
contractAbi, err :=
abi.JSON(strings.NewReader(string(contracts.NewUserABI)))
if err != nil {
glog.Fatal("ABI error",err)
}
for _, vLog := range logs {
//fmt.Println(string(vLog))
err := contractAbi.Unpack(&tempEvents, "userActivated", vLog.Data)
if err != nil {
glog.Fatal(err)
}
fmt.Println(tempEvents.ContractAddr.Hex(),tempEvents.Owner.Hex())
}
if err!=nil{
glog.Fatal(err.Error())
}
return ""
}
My event structure is here
type Event struct {
Owner common.Address
ContractAddr common.Address
}
But it lists both events, userActivated and userDeactivated even if I gave unPack parameter as "userActivated"
Is there any way to check event name in log data?