问题描述
我无法从合同中获得确切的哈希值。它似乎无法连接到特定的智能合约。 通过使用ransaction.createEthCallTransaction和ethCall从合同中获得价值是成功的。但是设置值不是。
我使用infura节点,其他设置很好。你能解释为什么我失败了吗?
private String store(int num){
Function function = new Function(
"store",Arrays.asList(new Uint256(num)),Collections.emptyList()
);return storeEthCall(function,num);
}
private String storeEthCall(Function function,int num){
Log.d(TAG,"storeEthCall()...");
String encodedFunction = FunctionEncoder.encode(function);
try {
BigInteger nonce = getNonce();
Transaction transaction = Transaction.createFunctionCallTransaction(credentials.getAddress(),nonce,BigInteger.valueOf(100),BigInteger.valueOf(50000L),"0x1ae7954BC0f3CfAAb7bd4562C71a6C17d7cDBd4c",(BigInteger.valueOf(num)),encodedFunction );
EthSendTransaction transactionResponse = web3j.ethSendTransaction(transaction).sendAsync().get();
System.out.println(transactionResponse.getResult());
Log.d(TAG,"Hash : "+transactionResponse.getTransactionHash());
} catch (ExecutionException e) {
e.printstacktrace();
return "fail";
} catch (InterruptedException e) {
e.printstacktrace();
return "fail";
}
return "success";
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)