【问题标题】:Go-Ethereum: Android Smart Contract Interaction IssueGo-Ethereum:Android 智能合约交互问题
【发布时间】:2017-07-19 14:02:23
【问题描述】:

我正在尝试使用 go-ethereum 库通过移动设备 (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 区块链上部署的智能合约成功交互。

实际行为

对于二传手(根据合同): 'abi: 不能使用 slice 作为类型字符串作为参数'

对于吸气剂(根据合同): 'abi: 无法将字符串解组到 []interface {}'

重现行为的步骤

1.) 通过手机连接到 Rinkeby 测试网

2.) 通过手机创建帐户

3.) 通过桌面部署智能合约

4.) 尝试通过移动设备与智能合约进行交互

底线

如果有人能够通过 go-ethereum android 与智能合约进行交互, 我将不胜感激。

【问题讨论】:

    标签: android ethereum smartcontracts


    【解决方案1】:

    修复该问题。 https://github.com/ethereum/go-ethereum/pull/15402

    我正在等待反馈。

    【讨论】:

      猜你喜欢
      • 2021-03-12
      • 1970-01-01
      • 2018-12-07
      • 1970-01-01
      • 2020-03-14
      • 2018-12-20
      • 2021-11-08
      • 2021-11-15
      • 2023-01-31
      相关资源
      最近更新 更多