0
我試圖通過使用go-ethereum庫的移動(android)與智能合約進行交互。Go-Ethereum:Android智能合約交互問題
的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;
合同
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;
}
}
預期的行爲
與上Rinkeby blockchain部署智能合同成功的互動。
實際行爲
對於設定部(合同): 'ABI:不能使用切片類型字符串作爲參數'
對於吸氣劑(合同): 「ABI:不能解組串在爲[]接口{}」
步驟來重現行爲
1通過移動
2)連接到Rinkeby Testnet)創建通過移動
3.帳戶)通過部署桌面智能合同
4)儘量W /通過移動智能交互合同
底線
如果有人已經能夠通過中間人復仇的Android智能合同進行互動, 我希望得到一些assistanc即