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

> The eth_feeHistory JSON-RPC method returns historical gas fee data for a range of blocks. Use it on Hyperliquid EVM via Chainstack.

<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_feeHistory` JSON-RPC method returns historical gas fee data for a range of blocks. This method provides essential information for gas price estimation, including base fees, gas usage ratios, and priority fee percentiles.

<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

The method takes three parameters:

1. **Block count** - Number of blocks to retrieve fee history for
2. **Newest block** - The newest block to include in the range
3. **Reward percentiles** - Array of percentiles for priority fee rewards

### Parameter details

* `blockCount` (string, required) — Number of blocks in the requested range as a hexadecimal string (maximum 1024)
* `newestBlock` (string, required) — Block identifier: `"latest"`, `"earliest"`, `"pending"`, or a specific block number in hexadecimal
* `rewardPercentiles` (array, optional) — Array of percentile values (0-100) for priority fee rewards

## Response

The method returns historical fee data for the specified block range.

### Response structure

**Fee history object:**

* `oldestBlock` — The oldest block number in the range as a hexadecimal string
* `baseFeePerGas` — Array of base fees per gas for each block (including one extra for the next block)
* `gasUsedRatio` — Array of gas used ratios for each block (0.0 to 1.0)
* `reward` — Array of priority fee rewards at specified percentiles for each block

### Data interpretation

**Base fee analysis:**

* Base fees adjust automatically based on network congestion
* Higher base fees indicate network congestion
* Use base fee trends for gas price prediction
* Base fee array includes one extra element for the next block

**Gas usage patterns:**

* Gas used ratio indicates block fullness (0.0 = empty, 1.0 = full)
* Higher ratios suggest network congestion
* Consistent high ratios may indicate sustained demand
* Use for capacity planning and congestion analysis

**Priority fee insights:**

* On Hyperliquid, priority fees are currently always zero
* Percentile data will reflect this zero priority fee structure
* Transaction ordering is not based on priority fees
* Focus on base fee analysis for gas price optimization

## Usage example

### Basic implementation

```javascript theme={"system"}
// Get fee history from Hyperliquid
const getFeeHistory = async (blockCount = 4, newestBlock = 'latest', percentiles = [25, 50, 75]) => {
  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_feeHistory',
      params: [`0x${blockCount.toString(16)}`, newestBlock, percentiles],
      id: 1
    })
  });
  
  const data = await response.json();
  return data.result;
};

// Analyze fee trends
const analyzeFeeHistory = async () => {
  try {
    const feeHistory = await getFeeHistory();
    
    // Convert base fees from hex to decimal (in gwei)
    const baseFees = feeHistory.baseFeePerGas.map(fee => 
      parseInt(fee, 16) / 1e9
    );
    
    // Analyze gas usage ratios
    const avgGasUsage = feeHistory.gasUsedRatio.reduce((a, b) => a + b, 0) / feeHistory.gasUsedRatio.length;
    
    // Note: Priority fees are always zero on Hyperliquid
    const priorityFees = feeHistory.reward.map(block => 
      block.map(fee => parseInt(fee, 16) / 1e9)
    );
    
    return {
      oldestBlock: parseInt(feeHistory.oldestBlock, 16),
      baseFees: baseFees,
      averageGasUsage: avgGasUsage,
      priorityFees: priorityFees, // Will be all zeros on Hyperliquid
      recommendation: {
        baseFee: Math.max(...baseFees) * 1.1, // Add 10% buffer
        priorityFee: 0 // Always zero on Hyperliquid
      }
    };
  } catch (error) {
    console.error('Fee history analysis failed:', error);
    throw error;
  }
};

// Usage
analyzeFeeHistory()
  .then(analysis => {
    console.log('Fee Analysis:', analysis);
    console.log(`Recommended base fee: ${analysis.recommendation.baseFee.toFixed(2)} gwei`);
    console.log(`Priority fee: ${analysis.recommendation.priorityFee} gwei (always zero on Hyperliquid)`);
  })
  .catch(error => console.error('Error:', error));
```

## Hyperliquid-specific considerations

### Priority fees

**Important limitation:**

* Priority fees are always zero on Hyperliquid
* `eth_maxPriorityFeePerGas` always returns zero
* Transaction ordering is not based on priority fees
* Focus on base fee optimization for cost management

### Fee optimization

**Base fee analysis:**

* Monitor base fee trends for optimal transaction timing
* Use gas usage ratios to identify network congestion
* Plan batch operations during low base fee periods
* Implement base fee-based cost optimization strategies

## Example request

```shell Shell theme={"system"}
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_feeHistory","params":["0x4","latest",[25,50,75]],"id":1}' \
  https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm
```

## Use cases

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

* **Gas price estimation**: Calculate optimal gas prices for transactions
* **Wallet applications**: Provide users with fee estimation and recommendations
* **DeFi protocols**: Optimize transaction costs for automated operations
* **Trading platforms**: Minimize transaction costs for high-frequency operations
* **Analytics platforms**: Analyze network congestion and fee trends
* **Cost optimization**: Schedule transactions during low-fee periods
* **Fee prediction**: Build predictive models for future gas prices
* **Network monitoring**: Track network health and congestion patterns
* **Arbitrage bots**: Optimize transaction timing for profitability
* **Portfolio management**: Calculate transaction costs for portfolio operations
* **Automated systems**: Implement dynamic fee adjustment strategies
* **Research tools**: Study network economics and fee market dynamics
* **Development tools**: Test applications under various fee conditions
* **Infrastructure services**: Provide fee estimation APIs to other applications
* **Compliance tools**: Monitor transaction costs for regulatory reporting
* **Risk management**: Assess fee volatility risks for operations
* **Educational platforms**: Demonstrate gas market concepts and dynamics
* **Optimization services**: Provide fee optimization recommendations
* **Monitoring systems**: Alert on significant fee changes or anomalies
* **Integration services**: Connect fee data with external systems
* **Planning tools**: Plan transaction batches based on fee forecasts
* **Cost accounting**: Track and analyze transaction cost patterns
* **Performance optimization**: Optimize application performance based on fees
* **User experience**: Provide transparent fee information to users
* **Economic analysis**: Study the economic impact of fee structures

This method provides comprehensive fee market data, enabling cost-effective and efficient transaction management on the Hyperliquid EVM platform.

<Note>
  On Hyperliquid, priority fees are always zero (`eth_maxPriorityFeePerGas` always returns zero). Fee history data reflects past network conditions and may not predict future fees accurately during periods of high volatility. Focus on base fee analysis for gas price optimization.
</Note>


## OpenAPI

````yaml /openapi/hyperliquid_node_api/evm_eth_fee_history.json post /evm
openapi: 3.0.0
info:
  title: Hyperliquid EVM API - eth_feeHistory
  version: 1.0.0
servers:
  - url: >-
      https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274
security: []
paths:
  /evm:
    post:
      summary: eth_feeHistory
      description: >-
        Returns historical gas fee data for a range of blocks, including base
        fees and priority fees at specified percentiles.
      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_feeHistory
                  default: eth_feeHistory
                  description: The RPC method name
                params:
                  type: array
                  description: 'Parameters: [blockCount, newestBlock, rewardPercentiles]'
                  default:
                    - '0x4'
                    - latest
                    - - 25
                      - 50
                      - 75
                id:
                  type: integer
                  default: 1
                  description: Request identifier
            example:
              jsonrpc: '2.0'
              method: eth_feeHistory
              params:
                - '0x4'
                - latest
                - - 25
                  - 50
                  - 75
              id: 1
      responses:
        '200':
          description: Successful response with historical fee data
          content:
            application/json:
              schema:
                type: object
                properties:
                  jsonrpc:
                    type: string
                    description: JSON-RPC version
                  id:
                    type: integer
                    description: Request identifier
                  result:
                    type: object
                    properties:
                      oldestBlock:
                        type: string
                        description: >-
                          The oldest block number in the range as a hexadecimal
                          string
                      baseFeePerGas:
                        type: array
                        items:
                          type: string
                        description: Array of base fees per gas for each block
                      gasUsedRatio:
                        type: array
                        items:
                          type: number
                        description: Array of gas used ratios for each block
                      reward:
                        type: array
                        items:
                          type: array
                          items:
                            type: string
                        description: >-
                          Array of priority fee rewards at specified percentiles
                          for each block
              example:
                jsonrpc: '2.0'
                id: 1
                result:
                  oldestBlock: '0x1234'
                  baseFeePerGas:
                    - '0x3b9aca00'
                    - '0x3b9aca00'
                    - '0x3b9aca00'
                    - '0x3b9aca00'
                  gasUsedRatio:
                    - 0.5
                    - 0.6
                    - 0.4
                    - 0.7
                  reward:
                    - - '0x1'
                      - '0x2'
                      - '0x3'
                    - - '0x1'
                      - '0x2'
                      - '0x3'
                    - - '0x1'
                      - '0x2'
                      - '0x3'
                    - - '0x1'
                      - '0x2'
                      - '0x3'

````