eth_getTransactionReceipt - Optimism

This method retrieves the transaction receipt, which contains information about the transaction's execution, including status (success/failure), gas used, emitted logs, and the contract address if it was a contract creation. Receipts are only available for mined transactions. On Optimism, the receipt includes additional fields for L1 gas information: l1GasUsed, l1GasPrice, l1Fee, and l1FeeScalar, which are essential for understanding the full transaction cost.

Parameters

ParameterTypeDescriptionRequired
transactionHashDATA, 32 BytesThe hash of a transaction.Yes

Request

bashcurl --location 'https://shared.us-east-1.getblock.io/<ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
  "jsonrpc": "2.0",
  "method": "eth_getTransactionReceipt",
  "params": [
    "0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685"
  ],
  "id": "getblock.io"
}'
javascriptimport axios from 'axios'
let data = JSON.stringify({
  "jsonrpc": "2.0",
  "method": "eth_getTransactionReceipt",
  "params": [
    "0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685"
  ],
  "id": "getblock.io"
};

let config = {
  method: "post",
  maxBodyLength: Infinity,
  url: "https://shared.us-east-1.getblock.io/<ACCESS_TOKEN>",
  headers: {
    "Content-Type": "application/json",
  },
  data: data,
};

axios
  .request(config)
  .then((response) => {
    console.log(JSON.stringify(response.data));
  })
  .catch((error) => {
    console.log(error);
  });
pythonimport requests
import json

url = "https://shared.us-east-1.getblock.io/<ACESS_TOKEN>"

payload = json.dumps({
  "jsonrpc": "2.0",
  "method": "eth_getTransactionReceipt",
  "params": [
    "0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685"
  ],
  "id": "getblock.io"
})
headers = {
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
rs#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::builder()
        .build()?;

    let mut headers = reqwest::header::HeaderMap::new();
    headers.insert("Content-Type", "application/json".parse()?);

    let data = r#"{
  "jsonrpc": "2.0",
  "method": "eth_getTransactionReceipt",
  "params": [
    "0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685"
  ],
  "id": "getblock.io"
}"#;

    let json: serde_json::Value = serde_json::from_str(&data)?;

    let request = client.request(reqwest::Method::POST, "https://shared.us-east-1.getblock.io/<ACCESS_TOKEN>")
        .headers(headers)
        .json(&json);

    let response = request.send().await?;
    let body = response.text().await?;

    println!("{}", body);

    Ok(())
}

Response

A successful response returns the following:

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "blobGasUsed": "0x9c40",
        "blockHash": "0x3e4a6a9efc7e4db75269430a5683ae3c7505ab0848d7814bd1c73c76e6882467",
        "blockNumber": "0x9087826",
        "contractAddress": null,
        "cumulativeGasUsed": "0x8829cf",
        "daFootprintGasScalar": "0x190",
        "effectiveGasPrice": "0x15f",
        "from": "0xcde377407d9b819efc0e185aa2d442194c2233e6",
        "gasUsed": "0xbdbfe",
        "l1BaseFeeScalar": "0x146b",
        "l1BlobBaseFee": "0xa92fc3",
        "l1BlobBaseFeeScalar": "0xf79c5",
        "l1Fee": "0xae8f1995",
        "l1GasPrice": "0xcdb8f78",
        "l1GasUsed": "0x640",
        "logs": [
            {
                "address": "0x4200000000000000000000000000000000000006",
                "topics": [
                    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
                    "0x000000000000000000000000cde377407d9b819efc0e185aa2d442194c2233e6",
                    "0x0000000000000000000000004aed348173bbf17dfaeb91598321904c9323d36e"
                ],
                "data": "0x0000000000000000000000000000000000000000000000003c9217e5e606acd8",
                "blockNumber": "0x9087826",
                "transactionHash": "0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685",
                "transactionIndex": "0x23",
                "blockHash": "0x3e4a6a9efc7e4db75269430a5683ae3c7505ab0848d7814bd1c73c76e6882467",
                "blockTimestamp": "0x6a04ca05",
                "logIndex": "0xa0",
                "removed": false
            },
  ],
        "logsBloom": "0x440002000000000000001002020000000000000040000000000400004001090000000000200000000000001000001000004000000000000006000000002000000000000000000002000000080000000000000002000000000000000000000000100000000200000020800001012018000000000008040000400000100000000000000000080000000000000000000000000080000420000000000000100000008200000008000020000000000000000020000000008000080002000000000080000000020000000100000a0008000080180000000080000800000000000024000014080000040000200000000000002000000000000000000400010000000800",
        "status": "0x1",
        "to": "0x4aed348173bbf17dfaeb91598321904c9323d36e",
        "transactionHash": "0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685",
        "transactionIndex": "0x23",
        "type": "0x2"
    }
}

Response Parameters

Field NameData TypeFormatDescription
transactionHashstring32 bytes (0x + 64 hex chars)Hash that uniquely identifies the transaction
transactionIndexstringHexadecimalInteger position of the transaction within the block (e.g., "0x66")
blockHashstring32 bytes (0x + 64 hex chars)Hash of the block where this transaction was included
blockNumberstringHexadecimalBlock number where this transaction was included (e.g., "0xeff35f")
fromstring20 bytes (0x + 40 hex chars)Address of the sender who initiated the transaction
tostring or null20 bytes (0x + 40 hex chars)Address of the receiver. null when the transaction is a contract creation transaction
cumulativeGasUsedstringHexadecimalTotal amount of gas used when this transaction was executed in the block (sum of gas used by this and all preceding transactions in the same block)
gasUsedstringHexadecimalAmount of gas used by this specific transaction alone
effectiveGasPricestringHexadecimalActual value per gas deducted from sender's account. Before EIP-1559: equals transaction's gas price. After EIP-1559: equals baseFeePerGas + min(maxFeePerGas - baseFeePerGas, maxPriorityFeePerGas)
contractAddressstring or null20 bytes (0x + 40 hex chars)Contract address created if the transaction was a contract creation, otherwise null
logsarray of objects-Array of log objects generated by this transaction (events emitted by smart contracts)
logs[].addressstring20 bytes (0x + 40 hex chars)Address of the contract that generated the log
logs[].topicsarray of strings32 bytes eachArray of indexed log topics (first topic is usually the event signature hash)
logs[].datastringHexadecimalNon-indexed log data
logs[].blockNumberstringHexadecimalBlock number where this log was created
logs[].transactionHashstring32 bytes (0x + 64 hex chars)Hash of the transaction that created this log
logs[].transactionIndexstringHexadecimalTransaction's position in the block
logs[].blockHashstring32 bytes (0x + 64 hex chars)Hash of the block containing this log
logs[].logIndexstringHexadecimalPosition of this log in the block
logs[].removedbooleantrue/falsetrue if log was removed due to chain reorganization, false if valid
logsBloomstring256 bytes (0x + 512 hex chars)Bloom filter for light clients to quickly retrieve related logs
statusstring"0x0" or "0x1"Transaction status: "0x1" for success, "0x0" for failure (only for post-Byzantium transactions)
rootstring or null32 bytesPost-transaction state root (only for pre-Byzantium transactions, otherwise null)
typestringHexadecimalTransaction type: "0x0" (legacy), "0x1" (EIP-2930), "0x2" (EIP-1559), or Arbitrum-specific types (see below)
blobGasUsedstring or nullHexadecimalAmount of blob gas used for this transaction (only for EIP-4844 blob transactions)
blobGasPricestring or nullHexadecimalActual value per gas deducted from sender's account for blob gas (only for EIP-4844 blob transactions)

Use Case

The eth_getTransactionReceipt method is commonly used for:

  • Transaction confirmation
  • Event log processing
  • Contract deployment verification
  • Gas usage analysis
  • L1 fee calculation

Error handling

Status CodeError MessageCause
404Not FoundMissing or invalid ACCESS_TOKEN.
-32602Invalid argument<ul><li>Invalid transaction hash</li></ul>

Integration with Web3

javascriptimport { ethers } from "ethers";
const RPC_URL = "https://shared.us-east-1.getblock.io/<ACCESS_TOKEN>";
const provider = new ethers.JsonRpcProvider(RPC_URL);
async function Call() {
  try {
     const result = await provider.send( "eth_getTransactionReceipt",
  [
   "0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685"
 ]);    
console.log("The result:", result);
    return result;
  } catch (error) {
    console.error("The error:", error);
    throw error;
  }
}
jsximport { createPublicClient, http } from 'viem';
import { optimism } from 'viem/chains';

// Create Viem client with GetBlock
const client = createPublicClient({
  chain: optimism,
  transport: http('https://shared.us-east-1.getblock.io/<ACCESS_TOKEN>'),
});

// Using the method through Viem
async function Call() {
    try {
        // Method-specific Viem implementation
        const result = await client.request({
         method: "eth_getTransactionReceipt",
         params: ["0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685"]});
        console.log('Result:', result);
        return result;
    } catch (error) {
        console.error('Viem Error:', error);
        throw error;
    }
}