Getting started with TheRPC
Ethereum/Core API/eth_getTransactionByBlockNumberAndIndex

eth_getTransactionByBlockNumberAndIndex

The eth_getTransactionByBlockNumberAndIndex method returns detailed information about a transaction by specifying its position (index) within a block identified by the block's number or tag. This method is particularly useful for retrieving transactions from known block heights or special blocks like "latest".

Use Cases

  • Real-time transaction monitoring
  • Block explorer functionality
  • Specific transaction analysis
  • Historical data extraction
  • Transaction verification
  • Sequential transaction processing
  • Smart contract interaction analysis
  • Mempool investigation (using "pending" tag)

Method Details

This method locates a transaction using both a block number (or tag) and the transaction's index within that block.

Parameters:

Block number in hex format or tags: latest, earliest, pending, safe, finalized

The transaction's index position in the block (hexadecimal)

Returns:

The transaction object, or null if not found

Hash of the block containing this transaction

Block number containing this transaction (hex)

Address of the sender

Gas provided by the sender (hex)

Gas price in wei (hex)

Maximum fee per gas (EIP-1559 transactions)

Maximum priority fee per gas (EIP-1559 transactions)

Transaction hash

Transaction data payload

Number of transactions from sender prior to this one (hex)

Recipient address, null for contract creation transactions

Integer of the transaction's position in the block (hex)

Value transferred in wei (hex)

Transaction type (0=legacy, 1=EIP2930, 2=EIP1559)

List of addresses and storage keys (EIP-2930 and EIP-1559)

Chain ID specified in the transaction

V parameter of the signature

R parameter of the signature

S parameter of the signature

Response Example

{
	"jsonrpc": "2.0",
	"id": 1,
	"result": {
		"blockHash": "0x0f2c90d18695045ede8b52476bba47db4c99ad8e9c748dd64147dcb698e88d5f",
		"blockNumber": "0x1194bb0",
		"from": "0xef3a770aec2e5e97994c8f0e283e7992e2c39a2a",
		"gas": "0x2b13c",
		"gasPrice": "0x342770c00",
		"maxFeePerGas": "0x342770c00",
		"maxPriorityFeePerGas": "0x3b9aca00",
		"hash": "0xa1c2c6b23cec00cdfa10a2bc30357c4250a2efb3cdf3c4d5c71e8b90ccb9071d",
		"input": "0x095ea7b30000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
		"nonce": "0x1a8",
		"to": "0x6982508145454ce325ddbe47a25d4ec3d2311933",
		"transactionIndex": "0x0",
		"value": "0x0",
		"type": "0x2",
		"accessList": [],
		"chainId": "0x1",
		"v": "0x1",
		"r": "0xea5232855738e1c0d1a6695f0a0c76de2db3c6c84eec9d7b7f4523d8dc0db1d5",
		"s": "0x2fd0b585c8e8df25e2e95ca8afe94b2d84a4c298d1e526f9afa0c2f1d492cd0d"
	}
}

Block Tag Meanings

  • latest: The most recently mined block
  • earliest: Genesis block (block 0)
  • pending: Currently pending block (transactions in mempool)
  • safe: Latest block considered safe by network
  • finalized: Latest block that has achieved finality

See also

Help Us Get Better!
Share this page and help us create an even better product for you.