Skip to main content

Services documentation

Use high performance APIs provided by Infura to scale your dapp or Snap.

EVM

eth_getTransactionByBlockHashAndIndex

Summary: Get transaction by block hash and index

This request returns information about a transaction for the provided block hash and transaction index position.

Parameters

blockHash
string
Pattern: ^0x[0-9a-f]{64}$
required

A string representing the hash (32 bytes) of a block.


transactionIndex
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
required

The position in the block in hexadecimal.

Returns

eth_getTransactionByBlockHashAndIndexResponse
object

Returns the transaction information or "not found".

blockHash
string
Pattern: ^0x[0-9a-f]{64}$

Block hash, 32 byte hex identifier for the block derived from the block header.

blockNumber
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Block number as hex-encoded unsigned integer.

from
string
Pattern: ^0x[0-9a-fA-F]{40}$

Sender's address.

hash
string
Pattern: ^0x[0-9a-f]{64}$

32 byte hex identifier for the transaction hash.

transactionIndex
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Transaction position.

Transaction Types:
Transaction Types
oneOf

Returns the transaction information or "not found".

Signed 1559 transaction
object

EIP-1559 transaction.

type
enum: 0 | 1 | 2 | 3

Hex-encoded byte for transaction type as introduced in EIP-2718. Use:

  • 0x00 for LegacyTxType
  • 0x01 for AccessListTxType
  • 0x02 for DynamicFeeTxType
  • 0x03 for BlobTxType

nonce
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Nonce.

to
string
Pattern: ^0x[0-9a-fA-F]{40}$

To address.

gas
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Gas limit.

value
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Value.

input
string
Pattern: ^0x[0-9a-f]*$

Input data.

maxPriorityFeePerGas
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Maximum fee per gas the sender is willing to pay to miners in wei.

maxFeePerGas
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

The maximum total fee per gas the sender is willing to pay (includes the network / base fee and miner / priority fee) in wei.

gasPrice
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

The effective gas price paid by the sender in wei. For transactions not yet included in a block, this value should be set equal to the max fee per gas. This field is DEPRECATED, please transition to using effectiveGasPrice in the receipt object going forward.

accessList
array of objects

EIP-2930 access list.

address
string
Pattern: ^0x[0-9a-fA-F]{40}$

Hex-encoded address.

storageKeys
array of strings

chainId
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Chain ID that this transaction is valid on.

v
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

ECDSA Recovery ID. An alternative to yParity.

r
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

ECDSA signature r.

s
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

ECDSA signature s.

Signed 2930 transaction
object

EIP-2930 transaction.

type
enum: 0 | 1 | 2 | 3

Hex-encoded byte for transaction type as introduced in EIP-2718. Use:

  • 0x00 for LegacyTxType
  • 0x01 for AccessListTxType
  • 0x02 for DynamicFeeTxType
  • 0x03 for BlobTxType

nonce
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Hex-encoded unsigned integer.

to
string
Pattern: ^0x[0-9a-fA-F]{40}$

To address.

gas
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Gas limit.

value
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Value.

input
string
Pattern: ^0x[0-9a-f]*$

Input data.

gasPrice
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

The gas price the sender is willing to be paid in wei.

accessList
array of objects

EIP-2930 access list.

address
string
Pattern: ^0x[0-9a-fA-F]{40}$

Hex-encoded address.

storageKeys
array of strings

chainId
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Chain ID that this transaction is valid on.

v
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

ECDSA Recovery ID. An alternative to yParity.

r
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

ECDSA signature r.

s
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

ECDSA signature s.

Signed legacy transaction
object

Signed Legacy Transaction.

type
enum: 0 | 1 | 2 | 3

Hex-encoded byte for transaction type as introduced in EIP-2718. Use:

  • 0x00 for LegacyTxType
  • 0x01 for AccessListTxType
  • 0x02 for DynamicFeeTxType
  • 0x03 for BlobTxType

nonce
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Hex-encoded unsigned integer.

to
string
Pattern: ^0x[0-9a-fA-F]{40}$

To address.

gas
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Gas limit.

value
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Value.

input
string
Pattern: ^0x[0-9a-f]*$

Input data.

gasPrice
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

The gas price the sender is willing to pay in wei.

chainId
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

Chain ID that this transaction is valid on.

v
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

ECDSA Recovery ID.

r
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

ECDSA signature r.

s
string
Pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$

ECDSA signature s.

Customize request
Parameter
Value
string
string

Request

curl https://linea-mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByBlockHashAndIndex",
"params": ["0x3ff53efeec688238a8ecc0a1404221d1be3723aa6531f12f4d635dc8e7824779","0x2"],
"id": 1
}'

Example response

{
"id": 1,
"jsonrpc": "2.0",
"result": {
"blockHash": "0x3ff53efeec688238a8ecc0a1404221d1be3723aa6531f12f4d635dc8e7824779",
"blockNumber": "0x49b95c",
"chainId": "0xe708",
"from": "0x05cc939ac053dc47366fe8032f9be00f5f33b508",
"gas": "0x439d0",
"gasPrice": "0x3dfd240",
"hash": "0x8b04f98bec033ccc46e13f01ed75e0b2b12c0dc8b7d7d16102cf2b4addeaa3b8",
"input": "0x83bd37f900011a51b19ce03dbe0cb44c1528e34a7edd7771e9af000...",
"nonce": "0x8d",
"r": "0xbc381ffdf71e5934df37913906305d88e06daf0051e69e42cabe4539e6fc4c58",
"s": "0x4d65409fdc70bb2d14926b038ac7a064d8cce583df50efb424438dfd9333d578",
"to": "0x2d8879046f1559e53eb052e949e9544bcb72f414",
"transactionIndex": "0x2",
"type": "0x0",
"v": "0x1ce33",
"value": "0x0"
}
}