Search in sources :

Example 1 with EthCall

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;
    }
}
Also used : Function(org.web3j.abi.datatypes.Function) Type(org.web3j.abi.datatypes.Type) Transaction(org.web3j.protocol.core.methods.request.Transaction) RawTransaction(org.web3j.crypto.RawTransaction) EthSendTransaction(org.web3j.protocol.core.methods.response.EthSendTransaction) EthCall(org.web3j.protocol.core.methods.response.EthCall)

Aggregations

Function (org.web3j.abi.datatypes.Function)1 Type (org.web3j.abi.datatypes.Type)1 RawTransaction (org.web3j.crypto.RawTransaction)1 Transaction (org.web3j.protocol.core.methods.request.Transaction)1 EthCall (org.web3j.protocol.core.methods.response.EthCall)1 EthSendTransaction (org.web3j.protocol.core.methods.response.EthSendTransaction)1