eth_getTransactionReceipt | Ethereum

·

The eth_getTransactionReceipt method is a fundamental Ethereum JSON-RPC API endpoint that allows developers to retrieve detailed information about the outcome of a specific transaction. By providing a transaction hash, this method returns a comprehensive receipt object that reveals critical insights such as execution status, gas consumption, contract deployment details, and emitted logs. It’s an essential tool for verifying transaction success, debugging smart contract interactions, and ensuring on-chain reliability.

Whether you're deploying a smart contract, transferring tokens, or interacting with decentralized applications (dApps), confirming that a transaction was processed correctly is crucial. The receipt provides irrefutable proof of execution and enables deeper analysis of on-chain activity.

Understanding Transaction Receipts

A transaction receipt is generated only after a transaction has been mined and included in a block. Unlike the transaction object itself—which contains sender, recipient, value, and data—the receipt reflects the result of executing that transaction.

This distinction is vital: while a transaction may be broadcasted and even confirmed in a block, it can still fail during execution due to out-of-gas errors, revert conditions in smart contracts, or invalid operations. The receipt’s status field captures this final outcome.

👉 Discover how blockchain APIs power real-time transaction verification and enhance dApp performance.

Parameters

Example: "0x2761f74e2f45d981a9d7553cbbcfbcc862cae416eb37a820300d4c19516d6fca"

Response Object

When the transaction has been mined, the response returns a receipt object with the following properties:

Key Use Cases

  1. Verifying Transaction Success
    After sending a token transfer or calling a function on a smart contract, use eth_getTransactionReceipt to confirm whether it succeeded (status: 1) or failed (status: 0). This avoids false assumptions based solely on block confirmation.
  2. Confirming Smart Contract Deployment
    When deploying a new contract, check the contractAddress field. If present and valid, your deployment was successful.
  3. Extracting Event Logs
    Smart contracts emit events (e.g., Transfer, Approval). These appear in the logs array and can be parsed to track user actions, update frontend interfaces, or feed off-chain analytics.
  4. Gas Usage Analysis
    Compare gasUsed against the gas limit to optimize future transactions and reduce costs.

👉 Learn how advanced blockchain tools streamline transaction monitoring and smart contract validation.

Practical Code Example Using Ethers.js

Below is a refined version of a Node.js script using Ethers.js and Chainstack’s provider to verify a transaction's status and extract key details:

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

// Initialize Chainstack provider for Ethereum mainnet
const provider = new ethers.JsonRpcProvider("YOUR_CHAINSTACK_ENDPOINT");

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

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

    console.log(`📦 Block Number: ${parseInt(receipt.blockNumber)}`);
    console.log(`⛽ Gas Used: ${receipt.gasUsed}`);
    console.log(`📌 Status: ${receipt.status === "0x1" ? "✅ Success" : "❌ Failed"}`);

    if (receipt.status === "0x1") {
      if (receipt.contractAddress) {
        console.log(`🎯 New contract deployed at: ${receipt.contractAddress}`);
      } else {
        console.log(`🔄 This was a standard transaction or function call.`);
      }

      if (receipt.logs.length > 0) {
        console.log(`📝 Found ${receipt.logs.length} log(s).`);
        // Further parsing can decode event data here
      }
    } else {
      console.log(`💥 Transaction failed. Check logic or gas settings.`);
    }
  } catch (error) {
    console.error("Error fetching receipt:", error.message);
  }
}

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

This script demonstrates robust error handling, clear output formatting, and conditional checks that reflect real-world development needs.

Frequently Asked Questions

Q: What does it mean if eth_getTransactionReceipt returns null?
A: A null response means the transaction has not yet been included in a block—it’s still pending. You should retry the call after a short delay.

Q: Can I get revert reasons from the receipt?
A: No. The receipt only shows status: 0 for failures. To retrieve human-readable revert messages, you need to simulate the call off-chain using tools like Tenderly or Alchemy’s debug APIs.

Q: Is eth_getTransactionReceipt available on all Ethereum nodes?
A: Yes, it's part of the standard JSON-RPC specification and supported by all compliant Ethereum clients (Geth, Nethermind, etc.) and infrastructure providers.

Q: How soon after sending a transaction can I expect a receipt?
A: Typically within 1–15 seconds on Ethereum mainnet, depending on network congestion and gas price. However, finality requires multiple confirmations.

Q: Does every transaction generate a receipt?
A: Only after being mined. Pending transactions do not have receipts. Once confirmed, the receipt becomes part of the blockchain's immutable record.

Core Keywords

With growing demand for transparency and reliability in decentralized systems, mastering methods like eth_getTransactionReceipt empowers developers to build more resilient and user-trustworthy applications.

👉 Access powerful blockchain APIs that simplify Ethereum interaction and accelerate dApp development.