I am following the guide here but I am not able to replicate what is being done in the guide.

var transferEvent LogTransfer

err := contractAbi.Unpack(&transferEvent, "Transfer", vLog.Data)
if err != nil {

First of all the Unpack function only takes two parameters, and using UnpackIntoInterface doesn't work for me neither.

I use the following code to try and feed the raw bytes into my struct using this Tx:

contractAbi, err := abi.JSON(strings.NewReader(string(uniswap.UniswapABI)))
            if err != nil {


            eLog, err := contractAbi.Unpack("Transfer", txReceiptLogs[i].Data)
            if err != nil {
                log.Fatal("Error unpacking into interface: %v", err)


This actually works for me and prints out:


Which is correct. However, when I try to do the same for the Uniswap Sync event which has the following hash:


I get an empty array, or more precisely a struct filled with two empty values.

{<nil> <nil>}

What I would want to know is how to get the unpack function also working for the Uniswap Sync event in the logs (I use this ABI). And if an updated example could be provided for the Unpack function in general that would be very nice as well. Thanks!

1 Answer 1


You can use the UnpackIntoInterface() method which takes three parameters

event := struct {
    Key   [32]byte
    Value [32]byte
_ = contractAbi.UnpackIntoInterface(&event, "ItemSet", vLog.Data)
fmt.Println(string(event.Key[:]))   // foo
fmt.Println(string(event.Value[:])) // bar

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.