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
| Property | Value |
|---|---|
| Address | 0x0200000000000000000000000000000000000003 |
| ConfigKey | feeManagerConfig |
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:
targetBlockRateminBlockGasCostmaxBlockGasCostblockGasCostStep
Fee Parameters
The Fee Manager allows configuration of the following parameters:
| Parameter | Description | Recommended Range |
|---|---|---|
| gasLimit | Maximum gas allowed per block | 8M - 100M |
| targetBlockRate | Target time between blocks (seconds) | 2 - 10 |
| minBaseFee | Minimum base fee (in wei) | 25 - 500 gwei |
| targetGas | Target gas spending over the last 10 seconds | 5M - 50M |
| baseFeeChangeDenominator | Controls how quickly base fee changes | 8 - 1000 |
| minBlockGasCost | Minimum gas cost for a block | 0 - 1B |
| maxBlockGasCost | Maximum gas cost for a block | > minBlockGasCost |
| blockGasCostStep | How 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 configgetFeeConfigLastChangedAt: retrieves the timestamp of the last block where the fee config was updatedsetFeeConfig: 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
-
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
-
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?