Skip to main content

Wallet API documentation

Directly integrate your dapp with the MetaMask extension.

Ethereum API
Multichain API

eth_getTransactionByBlockHashAndIndex

Summary: Returns information about a transaction by block hash and transaction index position.

Parameters

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

32 byte hex value


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

hex encoded unsigned integer

Returns

Transaction information
allOf

Transaction information

Contextual information

Contextual information

oneOf

Signed 4844 Transaction
allOf

Signed 4844 Transaction

EIP-4844 transaction.
object

EIP-4844 transaction.

type
string
Pattern: ^0x([0-9a-fA-F]?){1,2}$

type

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

nonce

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

hex encoded 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

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

The maximum total fee per gas the sender is willing to pay for blob gas 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

blobVersionedHashes
array of strings

List of versioned blob hashes associated with the transaction's EIP-4844 data blobs.

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

Chain ID that this transaction is valid on.

EIP-4844 transaction signature properties.

EIP-4844 transaction signature properties.

Signed 1559 Transaction
allOf

Signed 1559 Transaction

EIP-1559 transaction.
object

EIP-1559 transaction.

type
string
Pattern: ^0x2$

type

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

nonce

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

to

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.

EIP-1559 transaction signature properties.

EIP-1559 transaction signature properties.

Signed 2930 Transaction
allOf

Signed 2930 Transaction

EIP-2930 transaction.
object

EIP-2930 transaction.

type
string
Pattern: ^0x1$

type

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

nonce

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

to

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 willing to be paid by the sender 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.

EIP-2930 transaction signature properties.

EIP-2930 transaction signature properties.

Signed Legacy Transaction
allOf

Signed Legacy Transaction

Legacy transaction.
object

Legacy transaction.

type
string
Pattern: ^0x0$

type

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

nonce

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

to

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 willing to be paid by the sender in wei

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

Chain ID that this transaction is valid on.

Legacy transaction signature properties.

Legacy transaction signature properties.

Customize request
Parameter
Value
string
string

Connect your MetaMask wallet to run requests successfully.

Request

await window.ethereum.request({
"method": "eth_getTransactionByBlockHashAndIndex",
"params": [
"0xbf137c3a7a1ebdfac21252765e5d7f40d115c2757e4a4abee929be88c624fdb7",
"0x2"
],
});

Example response

{
"blockHash": "0x510efccf44a192e6e34bcb439a1947e24b86244280762cbb006858c237093fda",
"blockNumber": "0x422",
"chainId": 2018,
"from": "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
"gas": "0x5208",
"gasPrice": "0x3b9aca00",
"hash": "0xa52be92809541220ee0aaaede6047d9a6c5d0cd96a517c854d944ee70a0ebb44",
"input": "0x",
"nonce": "0x1",
"to": "0x627306090abab3a6e1400e9345bc60c78a8bef57",
"transactionIndex": "0x0",
"value": "0x4e1003b28d9280000",
"v": "0xfe7",
"r": "0x84caf09aefbd5e539295acc67217563438a4efb224879b6855f56857fa2037d3",
"s": "0x5e863be3829812c81439f0ae9d8ecb832b531d651fb234c848d1bf45e62be8b9"
}