eth_getTransactionReceipt | Ethereum

·

The eth_getTransactionReceipt method is a fundamental Ethereum JSON-RPC API call used to retrieve detailed information about the execution outcome of a transaction. By providing a transaction hash, developers can obtain a comprehensive receipt that reveals whether a transaction succeeded or failed, how much gas was consumed, whether a smart contract was deployed, and what logs were generated during execution.

This method is essential for blockchain developers, auditors, and dApp operators who need to monitor on-chain activity with precision. It plays a critical role in confirming finality and verifying smart contract interactions—especially after sending transactions that trigger complex logic or deploy new contracts.

👉 Discover powerful Ethereum tools to test eth_getTransactionReceipt in real time.


Understanding the Transaction Receipt

A transaction receipt is not the same as a transaction object. While the transaction contains data about the sender, recipient, value, and input, the receipt becomes available only after the transaction has been mined and included in a block. It provides post-execution details that are crucial for debugging and validation.

Key Fields in the Response

These fields make eth_getTransactionReceipt indispensable for building reliable blockchain applications.


Practical Use Cases

One of the most important use cases of eth_getTransactionReceipt is verifying contract deployment success. When deploying a smart contract via a transaction, there's no immediate guarantee it will succeed—even if the transaction appears on-chain.

For example:

By checking the status field and the presence of a contractAddress, developers can programmatically confirm whether a contract was successfully deployed.

Other key applications include:

👉 See how you can interact with Ethereum receipts using advanced developer tools.


Code Example: Verifying Transactions with ethers.js

Below is a practical implementation using ethers.js and Chainstack’s provider to fetch and interpret a transaction receipt:

const { ethers } = require("ethers");

// Connect to Ethereum mainnet via Chainstack
const provider = new ethers.JsonRpcProvider("YOUR_CHAINSTACK_ENDPOINT");

async function verifyTransaction(transactionHash) {
  try {
    // Fetch the transaction receipt
    const receipt = await provider.send("eth_getTransactionReceipt", [
      transactionHash,
    ]);

    if (!receipt) {
      console.log(`🔍 Transaction ${transactionHash} is still pending...`);
      return;
    }

    console.log(`📌 Transaction confirmed in block #${receipt.blockNumber}`);

    if (receipt.status === "0x1" || receipt.status === true) {
      console.log(`✅ Success: Transaction ${transactionHash} succeeded.`);

      if (receipt.contractAddress) {
        console.log(
          `🚀 Smart contract deployed at: ${receipt.contractAddress}`
        );
      } else {
        console.log(`💸 This was a standard transfer or function call.`);
      }

      console.log(`⛽ Gas used: ${receipt.gasUsed}`);
    } else {
      console.log(`❌ Failed: Transaction ${transactionHash} reverted.`);
    }

    if (receipt.logs && receipt.logs.length > 0) {
      console.log(`📝 ${receipt.logs.length} log(s) found. Processing events...`);
      // Process logs here (e.g., decode ERC-20 Transfer events)
    }
  } catch (error) {
    console.error("Error fetching receipt:", error);
  }
}

// Example usage
verifyTransaction(
  "0x2761f74e2f45d981a9d7553cbbcfbcc862cae416eb37a820300d4c19516d6fca"
);

This script demonstrates how to:


Frequently Asked Questions

Q: When should I use eth_getTransactionReceipt instead of eth_getTransactionByHash?
A: Use eth_getTransactionByHash to get details before execution (like nonce, gas price). Use eth_getTransactionReceipt after mining to check outcome, logs, and status.

Q: Why is my transaction receipt null?
A: A null response means the transaction hasn’t been included in a block yet. Wait a few seconds and retry—especially on high-congestion networks.

Q: Can I detect token transfers using the receipt?
A: Yes! Token transfers emit Transfer events stored in the logs array. You can decode these logs to extract from, to, and value.

Q: Does a successful status mean my smart contract function worked correctly?
A: Not always. A status of 1 means no reverts occurred, but business logic errors (e.g., incorrect amounts) won't affect this flag. Always validate expected outcomes separately.

Q: How fast should I poll for a receipt?
A: Start checking every 2–3 seconds. On Ethereum, average block times are ~12 seconds. Over-polling can lead to rate-limiting on public nodes.

👉 Start testing your own receipt queries with fast, reliable node access.


Core Keywords

These keywords reflect high-intent search queries from developers looking to debug, monitor, or integrate Ethereum-based systems—making them ideal for SEO optimization without compromising readability.

With proper implementation and monitoring workflows using eth_getTransactionReceipt, developers can build robust, transparent, and trustworthy decentralized applications.