Here is an example of a sucess:

  "hash": "0x17e0b789c7645eef46316d475419c02391181881f70eb0451bb13c29a2dd5133",
  "nonce": "0x14d",
  "blockHash": "0x7368ed3ff6d034cb38b8c521e272aa67a9fd50fe34ebbf0960fe47949d10a15d",
  "blockNumber": "0xd8e00e",
  "transactionIndex": "0x0",
  "from": "0x2096882843192129dd5b778531adefe4dfbeebed",
  "to": "0xbc948ec5aaa61a66b1641b1d403965701effacec",
  "value": "0x0",
  "gasPrice": "0x77359400",
  "gas": "0x4c4b40",
  "input": "0xea598cb00000000000000000000000000000000000000000000000000000000000002710",
  "publicKey": "0xbac5c6ab222cf37bbed7d34bd6d2ac87e5225730724dd0defb4724f9a8985e9eb6de8cb793f9c9c8f9277c53d7f5d6da814ed63570d3bc67bb78b070f18b78a0",
  "raw": "0xf88a82014d8477359400834c4b4094bc948ec5aaa61a66b1641b1d403965701effacec80a4ea598cb000000000000000000000000000000000000000000000000000000000000027101ca0a3e7242eeb8726f8b19643c3005af84e45fe4257f65e4f76e964a30aeede642aa057cf987e9afca2bc618dbe1e947075c4a0b9635a56e16f8af060a344ef3d096a",
  "r": "0xa3e7242eeb8726f8b19643c3005af84e45fe4257f65e4f76e964a30aeede642a",
  "s": "0x57cf987e9afca2bc618dbe1e947075c4a0b9635a56e16f8af060a344ef3d096a",
  "v": 28

Here is an example of a reverted transaction:

  "hash": "0xad3595a42afda6f3d340258448bf38b7aed995b1f3f830009b9e0aec708ba96a",
  "nonce": "0x106",
  "blockHash": "0xde32076d0028df0c2d800505ec91be55601ca4ae8d5d62a378d57447fe1129f1",
  "blockNumber": "0x16ceb65",
  "transactionIndex": "0x32",
  "from": "0xa9b8902b77004c2d9faa1bd5b044ea316cf8a1a3",
  "to": "0x78f2ae797f09915f51cc1cf64fd70b4f564290aa",
  "value": "0x38d7ea4c68000",
  "gasPrice": "0x2540be400",
  "gas": "0x5208",
  "input": "0x",
  "publicKey": "0x9149f6f823a88a351f1952e98f805b066899ec3a9f21c23b24f3e82914526cfbb41580a827db88c07cabedd9a690773706c66aab73cf9e3c255535a87ef6d0ad",
  "raw": "0xf86d8201068502540be4008252089478f2ae797f09915f51cc1cf64fd70b4f564290aa87038d7ea4c680008078a0f08254590fa90a7d570b239af144e1e3189574c6a18a99035809ea64d38fd201a04c31d1937694262b8e854626e6488ae7186b054aeb192cb2dd1cf3733e7f3094",
  "r": "0xf08254590fa90a7d570b239af144e1e3189574c6a18a99035809ea64d38fd201",
  "s": "0x4c31d1937694262b8e854626e6488ae7186b054aeb192cb2dd1cf3733e7f3094",
  "v": 120

How do I know which one was a success and which one was a failure? What is a general rule to apply to all transactions?

  • Those receipts are missing some fields status and gasUsed. They look more like transactions. In web3.js you have to call eth.getTransactionReceipt.
    – Ismael
    Mar 14 at 15:21
  • I am using the web3j (Java) and can't use the .js The call is "Transaction transaction = receipt.getReceiptByHash(txnHash, node);" the JSON I provided are the Transaction objects. I have to extract it either from the raw or r,s,v ... Mar 14 at 16:04
  • Or just do whatever is answered here: ethereum.stackexchange.com/questions/6002/transaction-status Thanks for a hint, didn't know that something was missing... Mar 14 at 16:11
  • 2
    web3j has a TransactionReceipt class. If status is missing perhaps the blockchain doesn't include EIP 658 that introduces it.
    – Ismael
    Mar 14 at 16:24

I use this code

import Logic.Connection.HttpClient;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.methods.response.EthGetTransactionReceipt;
import org.web3j.protocol.http.HttpService;

import java.io.IOException;

public class CheckReceipt {

    public String checkTransaction(String txhash, String node) throws IOException {
        HttpClient httpClient = new HttpClient();
        Web3j web3j = Web3j.build(new HttpService(node, httpClient.getHttpClient()));
        EthGetTransactionReceipt transactionReceipt = web3j.ethGetTransactionReceipt(txhash).send();
        String status = "success";
        if (transactionReceipt.getResult() != null && !transactionReceipt.hasError()) {
            if (transactionReceipt.getTransactionReceipt().isPresent()) {
                String statusOfTx = transactionReceipt.getTransactionReceipt().get().getStatus();
//                System.out.printf("The status is %s%n", statusOfTx);
                if (!statusOfTx.equals("0x1")) {
//                    System.out.printf("Transaction reverted: %s%n", transactionReceipt.getTransactionReceipt().get().toString());
                    status = "reverted";
                status = "failed";
            status = "failed";
        return status;
  • Works, I will edit the code. Please accept the edit and I will accept the answer. Mar 14 at 17:13
  • I think I'm not allowed to see and approve edits yet. when the big guys approve it, I will tell you to set it as an answer. :) @DamirOlejar
    – Majd TL
    Mar 14 at 17:18
  • Already accepted :) I hope the edit gets approved - Thanks! Mar 14 at 17:22
  • For anyone wondering what Logic.Connection.HttpClient is, it is just a call to a new instance of OKHttp (sorry my mistake I haven't expanded it). Mar 15 at 1:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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