0
votes

I am attempting to interact with a smart contract via mobile (android) using the go-ethereum library.

Android

final String address_string = "0x8607e627604495ae9812c22bb1c98bdcba581978";
String abi = "[{\"constant\":false,\"inputs\":[],\"name\":\"get_s\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"new_s\",\"type\":\"string\"}],\"name\":\"set_s\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"d_s\",\"type\":\"string\"}],\"payable\":false,\"type\":\"constructor\"}]";
Address address = Geth.newAddressFromHex(address_string);
BoundContract contract = Geth.bindContract(address, abi, ec);
CallOpts callOpts = Geth.newCallOpts();
callOpts.setContext(ctx);
callOpts.setGasLimit(31500);
System.out.println("OUTPUT: " + getString(contract, callOpts));

//Setter String to Test Contract
Interfaces params = Geth.newInterfaces(1);
Interface anInterface = Geth.newInterface();
anInterface.setString(teststring);
params.set(0,anInterface);
return contract.transact(opts, "set_s", params);

//Getter String from Test Contract
Interfaces args = Geth.newInterfaces(0);
Interfaces results = Geth.newInterfaces(1);
Interface result = Geth.newInterface();
result.setDefaultString();
results.set(0, result);
contract.call(opts, results, "get_s", args);
String string = results.get(0).getString();
return string;

Contract

pragma solidity ^0.4.9;

contract echo {
   string s;

   function echo(string d_s) {
           s = d_s;
   }

   function set_s(string new_s) {
           s = new_s;
   }

   function get_s() returns (string) {
           return s;
    }
}

Expected behaviour

Successful interaction with a deployed smart contract on the Rinkeby blockchain.

Actual behaviour

For setter (on contract): 'abi: cannot use slice as type string as argument'

For getter (on contract): 'abi: cannot unmarshal string in to []interface {}'

Steps to reproduce the behaviour

1.) Connect to Rinkeby Testnet via mobile

2.) Create an account via mobile

3.) Deploy a smart contract via desktop

4.) Try to interact w/ the smart contract via mobile

Bottom Line

If anyone has been able to interact with smart contracts through go-ethereum android, I would appreciate some assistance.

1

1 Answers

0
votes