Search in sources :

Example 6 with TransactionReceipt

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;
}
Also used : EthSendTransaction(org.web3j.protocol.core.methods.response.EthSendTransaction) Transaction(org.web3j.protocol.core.methods.request.Transaction) RawTransaction(org.web3j.crypto.RawTransaction) EthSendTransaction(org.web3j.protocol.core.methods.response.EthSendTransaction) TransactionReceipt(org.web3j.protocol.core.methods.response.TransactionReceipt) EthGetTransactionReceipt(org.web3j.protocol.core.methods.response.EthGetTransactionReceipt) BigInteger(java.math.BigInteger)

Aggregations

TransactionReceipt (org.web3j.protocol.core.methods.response.TransactionReceipt)6 EthGetTransactionReceipt (org.web3j.protocol.core.methods.response.EthGetTransactionReceipt)4 BigInteger (java.math.BigInteger)2 HashMap (java.util.HashMap)2 Credentials (org.web3j.crypto.Credentials)2 RawTransaction (org.web3j.crypto.RawTransaction)2 EthSendTransaction (org.web3j.protocol.core.methods.response.EthSendTransaction)2 HttpService (org.web3j.protocol.http.HttpService)2 Transaction (com.asf.appcoins.sdk.iab.entity.Transaction)1 Status (com.asf.appcoins.sdk.iab.entity.Transaction.Status)1 ArrayList (java.util.ArrayList)1 WorkItemImpl (org.drools.core.process.instance.impl.WorkItemImpl)1 TestWorkItemManager (org.jbpm.process.workitem.core.TestWorkItemManager)1 SendEtherWorkitemHandler (org.jbpm.process.workitem.ethereum.SendEtherWorkitemHandler)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 Type (org.web3j.abi.datatypes.Type)1 Transaction (org.web3j.protocol.core.methods.request.Transaction)1 EthTransaction (org.web3j.protocol.core.methods.response.EthTransaction)1 Log (org.web3j.protocol.core.methods.response.Log)1