For the complete documentation index, see llms.txt. This page is also available as Markdown.

eth_getTransactionReceipt - Optimism

Example code for the eth_getTransactionReceipt json-rpc method. Сomplete guide on how to use eth_getTransactionReceipt json-rpc in GetBlock.io Web3 documentation.

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

Parameter
Type
Description
Required

transactionHash

DATA, 32 Bytes

The hash of a transaction.

Yes

Request

curl --location 'https://go.getblock.us/<ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
  "jsonrpc": "2.0",
  "method": "eth_getTransactionReceipt",
  "params": [
    "0xca5a3c6bcb4a1ddf5e762687816b82dbcf869b8c5a4d7301b65f33f8b0f53685"
  ],
  "id": "getblock.io"
}'
import 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://go.getblock.us/<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);
  });

Response

A successful response returns the following:

Response Parameters

Field Name
Data Type
Format
Description

transactionHash

string

32 bytes (0x + 64 hex chars)

Hash that uniquely identifies the transaction

transactionIndex

string

Hexadecimal

Integer position of the transaction within the block (e.g., "0x66")

blockHash

string

32 bytes (0x + 64 hex chars)

Hash of the block where this transaction was included

blockNumber

string

Hexadecimal

Block number where this transaction was included (e.g., "0xeff35f")

from

string

20 bytes (0x + 40 hex chars)

Address of the sender who initiated the transaction

to

string or null

20 bytes (0x + 40 hex chars)

Address of the receiver. null when the transaction is a contract creation transaction

cumulativeGasUsed

string

Hexadecimal

Total 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)

gasUsed

string

Hexadecimal

Amount of gas used by this specific transaction alone

effectiveGasPrice

string

Hexadecimal

Actual 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)

contractAddress

string or null

20 bytes (0x + 40 hex chars)

Contract address created if the transaction was a contract creation, otherwise null

logs

array of objects

-

Array of log objects generated by this transaction (events emitted by smart contracts)

logs[].address

string

20 bytes (0x + 40 hex chars)

Address of the contract that generated the log

logs[].topics

array of strings

32 bytes each

Array of indexed log topics (first topic is usually the event signature hash)

logs[].data

string

Hexadecimal

Non-indexed log data

logs[].blockNumber

string

Hexadecimal

Block number where this log was created

logs[].transactionHash

string

32 bytes (0x + 64 hex chars)

Hash of the transaction that created this log

logs[].transactionIndex

string

Hexadecimal

Transaction's position in the block

logs[].blockHash

string

32 bytes (0x + 64 hex chars)

Hash of the block containing this log

logs[].logIndex

string

Hexadecimal

Position of this log in the block

logs[].removed

boolean

true/false

true if log was removed due to chain reorganization, false if valid

logsBloom

string

256 bytes (0x + 512 hex chars)

Bloom filter for light clients to quickly retrieve related logs

status

string

"0x0" or "0x1"

Transaction status: "0x1" for success, "0x0" for failure (only for post-Byzantium transactions)

root

string or null

32 bytes

Post-transaction state root (only for pre-Byzantium transactions, otherwise null)

type

string

Hexadecimal

Transaction type: "0x0" (legacy), "0x1" (EIP-2930), "0x2" (EIP-1559), or Arbitrum-specific types (see below)

blobGasUsed

string or null

Hexadecimal

Amount of blob gas used for this transaction (only for EIP-4844 blob transactions)

blobGasPrice

string or null

Hexadecimal

Actual 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 Code
Error Message
Cause

404

Not Found

Missing or invalid ACCESS_TOKEN.

-32602

Invalid argument

  • Invalid transaction hash

Integration with Web3

Last updated

Was this helpful?