use of org.web3j.protocol.core.methods.response.EthCall in project jbpm-work-items by kiegroup.
the class EthereumUtils method queryExistingContract.
public static Object queryExistingContract(Credentials credentials, Web3j web3j, String contractAddress, String contractMethodName, List<Type> contractMethodInputTypes, List<TypeReference<?>> contractMethodOutputTypes) throws Exception {
Function function = getFunction(contractMethodName, contractMethodInputTypes, contractMethodOutputTypes);
Transaction transaction = Transaction.createEthCallTransaction(credentials.getAddress(), contractAddress, getEncodedFunction(function));
EthCall response = web3j.ethCall(transaction, DefaultBlockParameterName.LATEST).sendAsync().get();
List<Type> responseTypeList = FunctionReturnDecoder.decode(response.getValue(), function.getOutputParameters());
if (responseTypeList != null && responseTypeList.size() > 0) {
return responseTypeList.get(0).getValue();
} else {
return null;
}
}
Aggregations