githubEdit

eth_getTransactionByBlockNumberAndIndex - Polygon

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

The eth_getTransactionByBlockNumberAndIndex method returns information about a transaction by block number and transaction index position.

Parameters

Parameter
Type
Required
Description

blockNumber

string

Yes

Block number in hex, or "latest", "earliest", "pending"

transactionIndex

string

Yes

Transaction index position in hexadecimal

Request

cURL
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_getTransactionByBlockNumberAndIndex",
    "params": ["0x3A2B5C7", "0x0"],
    "id": "getblock.io"
}'

Response

response.json
{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "hash": "0x...",
        "blockNumber": "0x3A2B5C7",
        "from": "0x...",
        "to": "0x...",
        "value": "0x..."
    }
}

Response Parameters

Field
Type
Description

jsonrpc

string

JSON-RPC version (2.0)

id

string

Request identifier

result

varies

Transaction object or null if not found

Use Case

The eth_getTransactionByBlockNumberAndIndex method is useful for:

  • Sequential block scanning

  • Transaction indexing

  • Historical data extraction

  • Block explorer functionality

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid ACCESS-TOKEN

-32600

Invalid Request

Malformed request body

-32602

Invalid params

Invalid method parameters

Web3 Integration

Last updated

Was this helpful?