Granite Upgrade Activates in00d:00h:00m:00sLearn more
Precompiles

Fee Manager

Configure dynamic fee parameters and gas costs for your Avalanche L1 blockchain.

Overview

The Fee Manager allows you to configure the parameters of the dynamic fee algorithm on-chain. This gives you control over:

  • Gas limits and target block rates
  • Base fee parameters
  • Block gas cost parameters
PropertyValue
Address0x0200000000000000000000000000000000000003
ConfigKeyfeeManagerConfig

Configuration

You can activate this precompile in your genesis file:

{
  "config": {
    "feeManagerConfig": {
      "blockTimestamp": 0,
      "adminAddresses": ["0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"],
      "initialFeeConfig": {
        "gasLimit": 20000000,
        "targetBlockRate": 2,
        "minBaseFee": 1000000000,
        "targetGas": 100000000,
        "baseFeeChangeDenominator": 48,
        "minBlockGasCost": 0,
        "maxBlockGasCost": 10000000,
        "blockGasCostStep": 500000
      }
    }
  }
}

The following parameters were deprecated by the Granite upgrade:

  • targetBlockRate
  • minBlockGasCost
  • maxBlockGasCost
  • blockGasCostStep

Fee Parameters

The Fee Manager allows configuration of the following parameters:

ParameterDescriptionRecommended Range
gasLimitMaximum gas allowed per block8M - 100M
targetBlockRateTarget time between blocks (seconds)2 - 10
minBaseFeeMinimum base fee (in wei)25 - 500 gwei
targetGasTarget gas spending over the last 10 seconds5M - 50M
baseFeeChangeDenominatorControls how quickly base fee changes8 - 1000
minBlockGasCostMinimum gas cost for a block0 - 1B
maxBlockGasCostMaximum gas cost for a block> minBlockGasCost
blockGasCostStepHow quickly block gas cost changes< 5M

Interface

interface IFeeManager {
  struct FeeConfig {
    uint256 gasLimit;
    uint256 targetBlockRate;
    uint256 minBaseFee;
    uint256 targetGas;
    uint256 baseFeeChangeDenominator;
    uint256 minBlockGasCost;
    uint256 maxBlockGasCost;
    uint256 blockGasCostStep;
  }
  
  event FeeConfigChanged(address indexed sender, FeeConfig oldFeeConfig, FeeConfig newFeeConfig);

  function setFeeConfig(
    uint256 gasLimit,
    uint256 targetBlockRate,
    uint256 minBaseFee,
    uint256 targetGas,
    uint256 baseFeeChangeDenominator,
    uint256 minBlockGasCost,
    uint256 maxBlockGasCost,
    uint256 blockGasCostStep
  ) external;

  function getFeeConfig() external view returns (
    uint256 gasLimit,
    uint256 targetBlockRate,
    uint256 minBaseFee,
    uint256 targetGas,
    uint256 baseFeeChangeDenominator,
    uint256 minBlockGasCost,
    uint256 maxBlockGasCost,
    uint256 blockGasCostStep
  );

  function getFeeConfigLastChangedAt() external view returns (uint256 blockNumber);
}

Access Control and Additional Features

The FeeManager precompile uses the AllowList interface to restrict access to its functionality.

In addition to the AllowList interface, the FeeManager adds the following capabilities:

  • getFeeConfig: retrieves the current dynamic fee config
  • getFeeConfigLastChangedAt: retrieves the timestamp of the last block where the fee config was updated
  • setFeeConfig: sets the dynamic fee config on chain. This function can only be called by an Admin, Manager or Enabled address.
  • FeeConfigChanged: an event that is emitted when the fee config is updated. Topics include the sender, the old fee config, and the new fee config.

You can also get the fee configuration at a block with the eth_feeConfig RPC method. For more information see here.

Best Practices

  1. Fee Configuration:

    • Test fee changes on testnet first
    • Monitor network congestion and adjust accordingly
    • Document rationale for fee parameter changes
    • Announce changes to validators in advance
  2. Security Considerations:

    • Use multi-sig for admin addresses
    • Monitor events for unauthorized changes
    • Have a plan for fee parameter adjustments
    • Keep backup of previous configurations

Implementation

You can find the Fee Manager implementation in the subnet-evm repository.

Interacting with the Precompile

For information on how to interact with this precompile, see:

Is this guide helpful?