If a transaction has a successful state it returns 0x1 but if the transaction has a failed state it returns 0x0. My questions is, what to return when the transaction has a pending status?

    public String estado(Web3j web3j, String txhash) {
    String status = "0";
    try {
        EthGetTransactionReceipt ethGetTransactionReceipt = web3j.ethGetTransactionReceipt(txhash).sendAsync().get();
        String status1 = ethGetTransactionReceipt.getTransactionReceipt().get().getStatus();
        System.out.println("estado :" + status1);
        if (status1.length() > 1) {
            status = status1.substring(2);
    } catch (InterruptedException e) {
    } catch (ExecutionException e) {
    return status;
  • It all depends on what you'll be using the function for right? You can return whatever you want, as long as the people using the function understand how it works. It might be nice to return an enum instead of a string though, like enum TxStatus { SUCCESS, FAILED, PENDING } for instance Commented Jan 18, 2019 at 15:45
  • Is that I want to know the value of the pending state because I have a method that gets the input data of the transaction and saves it in an ArrayList and calls the state method to obtain it and so add it to the end of the ArrayList so that it shows the status of the transaction . That's why I wanted to know what to return if the transaction is pending. Commented Jan 18, 2019 at 15:51
  • I'm not sure I completely understand what you mean, could you include the code where you're calling this function as well. And maybe explain in the original question what you want your end result to be? Commented Jan 18, 2019 at 15:53
  • What I want to know that returns if a transaction is pending, for example: null, 1, 2, 3, etc. Commented Jan 18, 2019 at 15:56
  • I'm not very good at writing English I'm sorry. Commented Jan 18, 2019 at 15:58

1 Answer 1


A transaction receipt is only available after the transaction has been mined.

For a pending transaction, you won't get any transaction receipt, so you also won't see any status.

  • Then will I get a null? Commented Jan 18, 2019 at 16:27
  • The easiest way to answer that would be to try it. My guess is that getTransactionReceipt will probably return null for pending transactions.
    – user19510
    Commented Jan 18, 2019 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.