I have a simple multicall contract in Solidity which has the following function:

function multiCall (address[] calldata targets,bytes[] calldata data) external view returns(Return[] memory returnData)

What I'd like to achieve is to call this function from Golang with the go-ethereum package. So far I could construct an array with address type, but couldn't for the bytes[] calldata data.

signature := "0x0902f1ac" // function modifier string
addressList := make([]common.Address, 0)
addressList = []common.Address{common.HexToAddress("0x58f876857a02d6762e0101bb5c46a8c1ed44dc16")}
sigs := make([]byte, 0)
sigs = []byte{signature} // warning: cannot use signature (variable of type string) as byte value in array or slice 

data, err := contractABI.Pack("multiCall", addressList, sigs )

callMsg := ethereum.CallMsg{
    To:   &contractAddress,
    Data: data, 

My question is, how should I correctly prepare the sigs slice and its content to use it as an input argument for my Solidity functions bytes[] calldata data input?

1 Answer 1


With go, the process of generating a signature should return bytes.


sig, err := MySigner.SignTypedData(data)

sig will be of type byte. In your example you are using an hexadecimal string.

It should not be converted to string if it's from go code, otherwise it has to be converted from hex to bytes.



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.