all I want to do is call a string from a smart contract I've written using go.
My smart contract is:
pragma solidity ^0.4.24;
contract String {
string store = "abcdef";
function getStore() public view returns (string) {
return store;
}
function setStore(string _value) public {
store = _value;
}
}
My go code looks like this:
package main
import (
"context"
"log"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
)
func main() {
client, _ := ethclient.Dial("RPC_SERVER")
defer client.Close()
contractAddr := common.HexToAddress("0xe78250E6c91bac56C7F5326fe5dD5db7f4f7FaaD")
callMsg := ethereum.CallMsg{
To: &contractAddr,
Data: common.FromHex("0x8da5cb5b"),
}
res, err := client.CallContract(context.Background(), callMsg, nil)
if err != nil {
log.Fatalf("Error calling contract: %v", err)
}
log.Printf("version: %s", common.BytesToAddress(res).Hex())
}
I do understand that it is calling the owner address of this contract and that's the problem, I don't know how to call the string.