0

So I'm playing around with go-ethereum in iOS and I'm having quite a bit of trouble trying to interact with a contract deployed to Rinkeby testnet, I'm very new to the whole blockchain technology so any help is appreciated.

All I'm trying to do is access a deployed contract and get the value of a string but the issue I'm having is I get this error when I try to make a call to a bound contract:

Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=go Code=1 "abi: cannot unmarshal string in to []interface {}" UserInfo={NSLocalizedDescription=abi: cannot unmarshal string in to []interface {}}

this is the code I'm using to make the call.

    // Declare the error variables
    var clientError: NSErrorPointer;
    var addressError: NSErrorPointer;
    var contractError: NSErrorPointer;

    // Get the bindContract from Rinkeby test network.
    let client = GethNewEthereumClient("https://rinkeby.infura.io/v3/398ed56d211646faaf010ca183de11f2", clientError);
    let contractAddress = GethNewAddressFromHex("0x7259667715d671Ee370d7788647f95Fe7C3B532d", addressError);

    guard let contractABI = ReadJsonResourceAsString(fileName: "InboxContractInterface", fileType: "json") else {
        print("[ViewController] failed to read the abi json as string.")
        return;
    }

    let boundContract = GethBindContract(contractAddress, contractABI, client, contractError);

    // Prepare the callOpts
    let callOpts = GethNewCallOpts();
    callOpts?.setGasLimit(300000);
    callOpts?.setContext(GethNewContext());


    // Prepare the results & params interfaces
    let results = GethNewInterfaces(1);
    let params = GethNewInterfaces(0);


    let stringResult = GethNewInterface();
    stringResult?.setDefaultString();
    try! results?.set(0, object: stringResult);

    // Make the call
    let methodName = "message";
    try! boundContract?.call(callOpts, out_: results, method: methodName, args: params);


    // Show results.
    print("[ViewController] message call result: " + (stringResult?.getString())!);

And this is my contract's code:

pragma solidity ^0.4.17;

contract Inbox {

    string public message;

    function Inbox (string initialMessage) public {
        message = initialMessage;
    }

    function setMessage (string newMessage) public {
        message = newMessage;

    }

}
Baek Ryun
  • 100
  • 1
  • 3
  • 14

1 Answers1

0

For anyone that might find the same issue after digging a bit more I found this issue for android: https://github.com/ethereum/go-ethereum/issues/14832

Luckily this is already fixed, so it was totally my fault for not using the latest version. I was using Geth v1.5.9 so after updating to v1.8.2 it finally worked, not sure which version in-between got fixed tho.

Baek Ryun
  • 100
  • 1
  • 3
  • 14