I have a simple solidity code
pragma solidity >0.4.24;
contract Store {
event ItemSet(bytes32 key, bytes32 value);
string public version;
mapping (bytes32 => bytes32) public items;
constructor(string memory _version) public {
version = _version;
}
function setItem(bytes32 key, bytes32 value) external {
items[key] = value;
emit ItemSet(key, value);
}
}
This is the Golang code to call the contract method
auth := bind.NewKeyedTransactor(privateKey)
auth.Nonce = big.NewInt(int64(nonce))
auth.Value = big.NewInt(0) // in wei
auth.GasLimit = uint64(300000) // in units
auth.GasPrice = big.NewInt(0)
address := common.HexToAddress("0xe17a5308f99584834823d2b27B328cb6abaabF11")
instance, err := store.NewStore(address, client)
if err != nil {
log.Fatal(err)
}
key := [32]byte{}
value := [32]byte{}
copy(key[:], []byte("foo"))
copy(value[:], []byte("bar"))
tx, err := instance.SetItem(auth, key, value)
if err != nil {
log.Fatal(err)
}
fmt.Printf("tx sent: %s", tx.Hash().Hex())
result, err := instance.Items(nil, key)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(result[:]))
instance.SetItem(auth, key, value) Calling the SetItem method is successful but when I try to get the Items
tx sent: 0xb8578fb80f7f49d833e05413c957fbd353babe1a993ed96c26b890a1f9cf60fd <-- This hash is for the SetItem
I am getting this error 2019/11/20 23:14:13 abi: attempting to unmarshall an empty string while arguments are expected
Please help on this if anyone has any solution please help me with this error .