> ## 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_getBlockTransactionCountByHash | Hyperliquid EVM

> The eth_getBlockTransactionCountByHash JSON-RPC method returns the number of transactions in a block by its hash. On Hyperliquid EVM.

<Info>
  This method is available on Chainstack. Not all Hyperliquid methods are available on Chainstack, as the open-source node implementation does not support them yet — see [Hyperliquid methods](/docs/hyperliquid-methods) for the full availability breakdown.
</Info>

The `eth_getBlockTransactionCountByHash` JSON-RPC method returns the number of transactions in a block by its hash. This method provides a lightweight way to get transaction count information without retrieving the full block data, making it efficient for block analysis and statistics.

## Parameters

The method takes one parameter:

1. **Block hash** - The hash of the block to get the transaction count for

### Parameter details

* `blockHash` (string, required) — The 32-byte hash of the block

## Response

The method returns the number of transactions in the specified block as a hexadecimal string, or `null` if the block is not found.

### Response structure

**Transaction count:**

* `result` — The number of transactions in the block as a hexadecimal string

### Data interpretation

**Count format:**

* Returned as hexadecimal string with `0x` prefix
* Convert to decimal for numerical operations
* `0x0` indicates an empty block (no transactions)
* `null` indicates the block hash doesn't exist

**Conversion example:**

```javascript theme={"system"}
// Convert hex count to decimal
const txCount = parseInt("0x5", 16); // 5 transactions
```

## Usage example

### Basic implementation

```javascript theme={"system"}
// Get transaction count for a block by hash on Hyperliquid
const getBlockTransactionCountByHash = async (blockHash) => {
  const response = await fetch('https://hyperliquid-mainnet.core.chainstack.com/YOUR_ENDPOINT/evm', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'eth_getBlockTransactionCountByHash',
      params: [blockHash],
      id: 1
    })
  });
  
  const data = await response.json();
  
  if (data.result === null) {
    throw new Error('Block not found');
  }
  
  return {
    hex: data.result,
    decimal: parseInt(data.result, 16)
  };
};

// Analyze multiple blocks for activity patterns
const analyzeBlockActivity = async (blockHashes) => {
  const results = [];
  
  for (const hash of blockHashes) {
    try {
      const count = await getBlockTransactionCountByHash(hash);
      results.push({
        blockHash: hash,
        transactionCount: count.decimal
      });
    } catch (error) {
      console.error(`Error processing block ${hash}:`, error);
      results.push({
        blockHash: hash,
        transactionCount: null,
        error: error.message
      });
    }
  }
  
  // Calculate statistics
  const validCounts = results
    .filter(r => r.transactionCount !== null)
    .map(r => r.transactionCount);
  
  if (validCounts.length === 0) {
    return { results, statistics: null };
  }
  
  const statistics = {
    totalBlocks: validCounts.length,
    totalTransactions: validCounts.reduce((sum, count) => sum + count, 0),
    averageTransactions: validCounts.reduce((sum, count) => sum + count, 0) / validCounts.length,
    maxTransactions: Math.max(...validCounts),
    minTransactions: Math.min(...validCounts),
    emptyBlocks: validCounts.filter(count => count === 0).length
  };
  
  return { results, statistics };
};

// Usage examples
const blockHash = "0x53e84f299e6893680383c6a53329574122a7292e5bb9397bb6a0b51b4db5957a";

getBlockTransactionCountByHash(blockHash)
  .then(count => console.log(`Block has ${count.decimal} transactions`))
  .catch(error => console.error('Error:', error));

// Analyze multiple blocks
const blockHashes = [
  "0x53e84f299e6893680383c6a53329574122a7292e5bb9397bb6a0b51b4db5957a",
  "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
];

analyzeBlockActivity(blockHashes)
  .then(analysis => console.log('Block Activity Analysis:', analysis))
  .catch(error => console.error('Error:', error));
```

## Efficiency benefits

### Lightweight queries

**Minimal data transfer:**

* Returns only the transaction count, not full block data
* Significantly smaller response than `eth_getBlockByHash`
* Faster response times for count-only queries
* Ideal for preliminary block analysis and statistics

### Performance optimization

**Conditional processing:**

* Check transaction count before deciding to process full block
* Skip empty blocks in analysis workflows
* Optimize processing based on block activity levels
* Implement efficient batch processing strategies

## Example request

<CodeGroup>
  ```shell Shell theme={"system"}
  curl -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params":["0x53e84f299e6893680383c6a53329574122a7292e5bb9397bb6a0b51b4db5957a"],"id":1}' \
    https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm
  ```

  ```python web3.py theme={"system"}
  from web3 import Web3

  w3 = Web3(Web3.HTTPProvider("YOUR_CHAINSTACK_ENDPOINT"))

  block_hash = "0x53e84f299e6893680383c6a53329574122a7292e5bb9397bb6a0b51b4db5957a"

  # Passing a block hash routes to eth_getBlockTransactionCountByHash
  count = w3.eth.get_block_transaction_count(block_hash)
  print(count)
  ```

  ```javascript ethers.js theme={"system"}
  import { JsonRpcProvider } from "ethers";

  const provider = new JsonRpcProvider("YOUR_CHAINSTACK_ENDPOINT");

  const blockHash =
    "0x53e84f299e6893680383c6a53329574122a7292e5bb9397bb6a0b51b4db5957a";

  // ethers v6 has no dedicated helper, so call the method directly
  const count = await provider.send("eth_getBlockTransactionCountByHash", [
    blockHash,
  ]);
  console.log(parseInt(count, 16));
  ```

  ```typescript viem theme={"system"}
  import { createPublicClient, http } from "viem";

  const client = createPublicClient({
    transport: http("YOUR_CHAINSTACK_ENDPOINT"),
  });

  const blockHash =
    "0x53e84f299e6893680383c6a53329574122a7292e5bb9397bb6a0b51b4db5957a";

  // Passing blockHash routes to eth_getBlockTransactionCountByHash
  const count = await client.getBlockTransactionCount({ blockHash });
  console.log(count);
  ```
</CodeGroup>

<Note>
  **Use your own endpoint in your code.** The code examples use a placeholder Chainstack endpoint (YOUR\_CHAINSTACK\_ENDPOINT) — replace it with your own Hyperliquid node endpoint from the [Chainstack console](https://console.chainstack.com/). The curl above uses a shared public endpoint for quick checks only; do not use it in production.
</Note>

## Use cases

The `eth_getBlockTransactionCountByHash` method is essential for applications that need to:

* **Block statistics**: Generate transaction count statistics and metrics
* **Network analysis**: Analyze blockchain activity patterns and trends
* **Performance optimization**: Optimize block processing based on transaction counts
* **Block explorers**: Display transaction counts in block listings efficiently
* **Analytics platforms**: Collect block activity data for analysis
* **Monitoring systems**: Track network activity and usage patterns
* **Development tools**: Optimize applications based on block activity levels
* **Data visualization**: Create charts and graphs of block activity over time

<Note>
  This method returns only the transaction count, including both regular transactions and system transactions from HyperCore. The count represents the total number of all transactions in the block. Use `eth_getBlockByHash` if you need the full block data including transaction details.
</Note>


## OpenAPI

````yaml openapi/hyperliquid_node_api/hyperevm/evm_eth_get_block_transaction_count_by_hash.json post /evm
openapi: 3.0.0
info:
  title: Hyperliquid EVM API - eth_getBlockTransactionCountByHash
  version: 1.0.0
servers:
  - url: >-
      https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274
security: []
paths:
  /evm:
    post:
      summary: eth_getBlockTransactionCountByHash
      description: Returns the number of transactions in a block by its hash.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - jsonrpc
                - method
                - params
                - id
              properties:
                jsonrpc:
                  type: string
                  enum:
                    - '2.0'
                  default: '2.0'
                  description: JSON-RPC version
                method:
                  type: string
                  enum:
                    - eth_getBlockTransactionCountByHash
                  default: eth_getBlockTransactionCountByHash
                  description: The RPC method name
                params:
                  type: array
                  description: 'Parameters: [blockHash]'
                  default:
                    - >-
                      0x53e84f299e6893680383c6a53329574122a7292e5bb9397bb6a0b51b4db5957a
                id:
                  type: integer
                  default: 1
                  description: Request identifier
            example:
              jsonrpc: '2.0'
              method: eth_getBlockTransactionCountByHash
              params:
                - >-
                  0x53e84f299e6893680383c6a53329574122a7292e5bb9397bb6a0b51b4db5957a
              id: 1
      responses:
        '200':
          description: Successful response with the transaction count
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                    description: JSON-RPC version
                  id:
                    type: integer
                    description: Request identifier
                  result:
                    type: string
                    description: >-
                      The number of transactions in the block as a hexadecimal
                      string
              example:
                jsonrpc: '2.0'
                id: 1
                result: '0x5'

````