> ## 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_getBlockTransactionCountByNumber | Fantom

> Fantom API method that returns the number of transactions in a block specified by block number or tag. This information can be useful for analytics purposes.

Fantom API method that returns the number of transactions in a block specified by block number or tag. This information can be useful for analytics purposes.

## 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.
  * `safe` and `finalized` — not supported on Fantom; the request fails with an `invalid argument` error. Fantom blocks are final as soon as they're produced, so use `latest`.
  * `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).

## Response

* `quantity` — an integer value representing how many transactions are included in the block.

## `eth_getBlockTransactionCountByNumber` code examples

```javascript ethers.js theme={"system"}
const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);

const getTransactionsCount = async (blockId) => {
    const count = await provider.send("eth_getBlockTransactionCountByNumber", [blockId]);
     console.log(count);
   };

   getTransactionsCount('latest')
```

```python web3.py theme={"system"}
from web3 import Web3  
node_url = "CHAINSTACK_NODE_URL" 

web3 = Web3(Web3.HTTPProvider(node_url)) 
print (web3.eth.get_block_transaction_count(79035660)) # A hex value starting with "0x" is accepted as well.
```

## Use case

`eth_getBlockTransactionCountByNumber` can be used to analyze how many transactions are included on the Fantom blockchain in a certain period. For instance, on average, a new block is generated on the Fantom mainnet every 3 seconds, resulting in approximately 1,200 blocks per hour. Using a Web3 library, one can inspect the past 1,200 blocks starting from the latest block and use `eth_getBlockTransactionCountByNumber` to find the number of transactions in each block to sum them.


## OpenAPI

````yaml openapi/fantom_node_api/eth_getBlockTransactionCountByNumber.json POST /mt_c524ad9781ae5dccd9ac6f5b0370e
openapi: 3.0.0
info:
  title: Fantom Node API
  version: 1.0.0
  description: This is an API for interacting with a Fantom node.
servers:
  - url: https://fantom-mainnet.core.chainstack.com
security: []
paths:
  /mt_c524ad9781ae5dccd9ac6f5b0370e:
    post:
      tags:
        - Blocks info
      summary: eth_getBlockTransactionCountByNumber
      operationId: getBlockTransactionCountByNumber
      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_getBlockTransactionCountByNumber
                params:
                  type: array
                  items:
                    type: string
                    title: Block identifier
                    description: The block number or tag.
                  default:
                    - latest
      responses:
        '200':
          description: The block transaction count information
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                  id:
                    type: integer
                  result:
                    type: string

````