Go Ethereum Mobile (Android) Contract ABI Error
I want to interact with Smart Contract in Ethereum from a mobile device (here Android). Smart Contract works great with Javascript API from ethereum. So I want to use Go Ethereum Mobile Client (1.6.0) (included in gradle). I could connect to the blockchain, get the peer count, read the balances, but interacting with the contract is my problem.
Creating a Java class using the "abigen" command line is fine. I only need to change "bool" to "boolean" and the class should be ready to go. Whenever I try to communicate, Go Ethereum throws an exception: this.Contract.call ()
So I just want to do the following:
Contract1 electionContract = new Contract1(contractAddress,node.getEthereumClient());
//Action 1
TransactOpts transactOpts = new TransactOpts();
transactOpts.setFrom(keyStore.getAccounts().get(0).getAddress());
transactOpts.setContext(gethcontext);
Transaction transaction = contract1.sendString(transactOpts,new BigInt(0),"String");
//Action 2
contract1.Results contract1=electionContract.getString(null,new BigInt(0),new BigInt(0));
Activity 1 Declaration (generated class)
protected Transaction sendString(TransactOpts opts, BigInt identifier, String teststring) throws Exception {
Interfaces args = Geth.newInterfaces(2);
args.set(0, Geth.newInterface());
args.get(0).setBigInt(identifier);
args.set(1, Geth.newInterface());
args.get(1).setString(teststring);
return this.Contract.transact(opts, "sendString", args); //at this point the error is thrown
When trying to send data (see step 1 above)
go.Universe$proxyerror: argument count mismatch: 1 for 2
Action Declaration 2
protected Results getString(CallOpts opts, BigInt randomID, BigInt randomID2) throws Exception {
Interfaces args = Geth.newInterfaces(2);
args.set(0, Geth.newInterface());
args.get(0).setBigInt(randomID);
args.set(1, Geth.newInterface());
args.get(1).setBigInt(randomID2);
Interfaces results = Geth.newInterfaces(2);
Interface result0 = Geth.newInterface();
result0.setDefaultString();
results.set(0, result0);
Interface result1 = Geth.newInterface();
result1.setDefaultBigInt();
results.set(1, result1);
if (opts == null) {
opts = Geth.newCallOpts();
}
this.Contract.call(opts, results, "getString", args); //at this point the error is thrown
Results result = new Results();
result.String = results.get(0).getString();
result.Count = results.get(1).getBigInt();
return result;
}
Trying to get data from a persistent function (so should be free)
go.Universe$proxyerror: `getString` abi: cannot use invalid as type ptr as argument //see action 2 below
ABI String Extract:
[ {
"constant": false,
"inputs": [{
"name": "randomID",
"type": "uint256"
}, {
"name": "randomString",
"type": "string"
}],
"name": "sendString",
"outputs": [],
"payable": false,
"type": "function"
}, {
"constant": true,
"inputs": [{
"name": "randomID",
"type": "uint256"
}, {
"name": "randomID2",
"type": "uint256"
}],
"name": "getString",
"outputs": [{
"name": "randomString",
"type": "string"
}, {
"name": "randomID",
"type": "uint256"
}],
"payable": false,
"type": "function"
}]
Here is a related github issue: https://github.com/ethereum/go-ethereum/issues/14363
source to share
No one has answered this question yet
Check out similar questions: