> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# eth_getTransactionByBlockNumberAndIndex | BNB Chain

BNB API method that retrieves information about a specific transaction based on the block number and the transaction index within the block. This information can be used to track transactions, debug issues, analyze data, and build decentralized applications on the BNB blockchain.

<Check>
  **Get your own node endpoint today**

  [Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required.

  You can sign up with your GitHub, X, Google, or Microsoft account.
</Check>

## Parameters

* `quantity or tag` — the integer of a block encoded as hexadecimal or the string with:

  * `latest` — the most recent block in the blockchain and the current state of the blockchain at the most recent block. A chain reorganization is to be expected.
  * `safe`—the block that received justification from the beacon chain. Although this block could be involved in a chain reorganization, it would necessitate either a coordinated attack by the majority of validators or severe propagation latency.
  * `finalized`—the block accepted as canonical by more than 2/3 of the validators. A chain reorganization is extremely unlikely, requiring burning at least 1/3 of the staked BNB.
  * `earliest` — the earliest available or genesis block
  * `pending`—the pending state and transactions block. This is the current state of transactions that have been broadcast to the network but have not yet been included in a block.

<Note>
  See the [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block) and [How The Merge Impacts Ethereum’s Application Layer](https://blog.ethereum.org/2021/11/29/how-the-merge-impacts-app-layer).
</Note>

* `quantity` — the integer identifying the transaction index position within the block, encoded as hexadecimal.

## Response

* `object` — the transaction response object, or `null` if no transaction is found:
  * `blockHash` — the block hash. Identifies the block in which the transaction was included. This field is `null` for transactions that have not yet been included in a block.
  * `blockNumber` — the number of the block in which the transaction was included. This field is `null` for transactions that have not yet been included in a block.
  * `from` — the address of the sender who initiated the transaction.
  * `gas` — the units of gas included in the transaction by the sender.
  * `gasPrice` — the price of gas in Wei included in the transaction by the sender.
  * `maxFeePerGas` — the maximum amount the transaction's sender is willing to pay per unit of gas for the transaction to be executed.
  * `maxPriorityFeePerGas` — the maximum priority fee the transaction sender is willing to pay per gas unit.
  * `hash` — the hash that uniquely identifies the transaction.
  * `input` — the optional input data sent with the transaction, usually used to interact with smart contracts.
  * `nonce` — a counter identifying the transaction's number sent by the sender's wallet. It essentially identifies how many transactions an account has made. Used to ensure each transaction is executed only once.
  * `to` — the recipient's address of the transaction if it was a transaction to an address. For contract creation transactions, this field is `null`.
  * `transactionIndex` — the index of the transaction within the block. It is `null` for transactions that have not yet been included in a block.
  * `value` — the value of the native token transferred along with the transaction in Wei.
  * `type` — the [type](https://ethereum.org/en/developers/docs/transactions/#types-of-transactions) of the transaction. `0` indicates a regular transfer; `2` indicates a contract creation or smart contract function call.
  * `accessList` — a list of [authorized addresses and storage keys](https://eips.ethereum.org/EIPS/eip-2930#:~:text=The%20accessList%20specifies%20a%20list,of%20accessing%20outside%20the%20list.) the transaction plans to interact with.
  * `v` — the recovery parameter in the [Ethereum Signature Algorithm](https://ethereum.org/en/glossary/#ecdsa) (ECDSA).
  * `r` — the first component of the signature in the [Ethereum Signature Algorithm](https://ethereum.org/en/glossary/#ecdsa) (ECDSA).
  * `s` — the second component of the signature in the [Ethereum Signature Algorithm](https://ethereum.org/en/glossary/#ecdsa) (ECDSA).

## `eth_getTransactionByBlockNumberAndIndex` code examples

<CodeGroup>
  ```javascript web3.js theme={"system"}
  const { Web3 } = require("web3");
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const web3 = new Web3(NODE_URL);

  async function getTransaction() {
    const transaction = await web3.eth.getTransactionFromBlock("37286315", 22);
    console.log(transaction);
  }

  getTransaction();
  ```

  ```javascript ethers.js theme={"system"}
  const ethers = require('ethers');
  const NODE_URL = "CHAINSTACK_NODE_URL";
  const provider = new ethers.JsonRpcProvider(NODE_URL);

  const getTransaction = async (blocNumber, index) => {
      const transaction = await provider.send("eth_getTransactionByBlockNumberAndIndex", [blocNumber, index]);
      console.log(transaction);
    }
    
    getTransaction("latest", "0x1");
  ```

  ```python web3.py theme={"system"}
  from web3 import Web3  
  node_url = "CHAINSTACK_NODE_URL" 

  web3 = Web3(Web3.HTTPProvider(node_url)) 
  print(web3.eth.get_transaction_by_block(37286315, 22)) # Hex encoded parameters starting with "0x" are accepted as well.
  ```
</CodeGroup>

## Use case

The `eth_getTransactionByBlockNumberAndIndex` can be used to retrieve transaction details from a block; for example, an analytics tool systematically scans each block for transactions by sequentially incrementing the block number and cycling through the transactions within each block using the transaction index. For each transaction, it retrieves detailed information such as the value transferred, the gas price, the sender and receiver addresses, and the input data, which can contain calls to smart contracts.


## OpenAPI

````yaml /openapi/bnb_node_api/eth_getTransactionByBlockNumberAndIndex.json POST /35848e183f3e3303c8cfeacbea831cab
openapi: 3.0.0
info:
  title: BNB Node API
  version: 1.0.0
  description: This is an API for interacting with an BNB node.
servers:
  - url: https://bsc-mainnet.core.chainstack.com
security: []
paths:
  /35848e183f3e3303c8cfeacbea831cab:
    post:
      tags:
        - Transactions info
      summary: eth_getTransactionByBlockNumberAndIndex
      operationId: getTransactionByBlockNumberAndIndex
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                id:
                  type: integer
                  default: 1
                jsonrpc:
                  type: string
                  default: '2.0'
                method:
                  type: string
                  default: eth_getTransactionByBlockNumberAndIndex
                params:
                  type: array
                  items:
                    anyOf:
                      - type: string
                        title: Block number
                      - type: string
                        title: Transaction index
                  default:
                    - '0x238f1ab'
                    - '0x58'
      responses:
        '200':
          description: The transaction information
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: object

````