use of org.web3j.protocol.core.methods.response.TransactionReceipt in project jbpm-work-items by kiegroup.
the class EthereumUtils method transactExistingContract.
public static TransactionReceipt transactExistingContract(Credentials credentials, Web3j web3j, int etherAmount, BigInteger gasPrice, BigInteger gasLimit, String toAddress, String methodName, List<Type> methodInputTypes, List<TypeReference<?>> methodOutputTypes, boolean waitForReceipt, int sleepDuration, int attempts) throws Exception {
BigInteger etherAmountToSend = BigInteger.valueOf(etherAmount);
Transaction transaction = Transaction.createFunctionCallTransaction(credentials.getAddress(), getNextNonce(credentials.getAddress(), web3j), gasPrice, gasLimit, toAddress, etherAmountToSend, getEncodedFunction(methodName, methodInputTypes, methodOutputTypes));
EthSendTransaction transactionResponse = web3j.ethSendTransaction(transaction).sendAsync().get();
if (waitForReceipt) {
TransactionReceipt transReceipt = waitForTransactionReceipt(transactionResponse.getTransactionHash(), sleepDuration, attempts, web3j);
return transReceipt;
}
// we dont have a transaction receipt
logger.warn("Unable to retrieve transaction receipt.");
return null;
}
Aggregations