The feemarket module from cosmos/evm implements EIP-1559 dynamic fee pricing for Cosmos SDK chains with EVM compatibility.
This is part of cosmos/evm, not standard Cosmos SDK. For conceptual understanding of EIP-1559, see EIP-1559 Fee Market.

Parameters

The module contains the following parameters (types, proto):
ParameterTypeDefaultDescription
NoBaseFeeboolfalseDisables EIP-1559 base fee (enables legacy pricing)
BaseFeeChangeDenominatoruint328Controls max base fee change per block (higher = more stable)
ElasticityMultiplieruint322Determines target block utilization (2 = 50% target)
EnableHeightint640Block height to activate fee market (0 = genesis)
BaseFeesdk.Dec1000000000Current base fee (auto-adjusts each block)
MinGasPricesdk.Dec0Minimum gas price floor (cannot go below)
MinGasMultipliersdk.Dec0.5Minimum gas used multiplier for gas wanted

Parameter Details

Parameter Storage Format

sdk.Dec (LegacyDec) values are stored as strings with 18 decimal precision (cosmos-sdk):
Human ValueStored StringFormula
1 unit”1000000000000000000”1 × 10^18
0.5 (50%)“500000000000000000”0.5 × 10^18
1 billion”1000000000000000000000000000”10^9 × 10^18

Configuration

Adjust parameters to achieve specific network behaviors (params validation):
GoalParameterAdjustmentEffect
Faster fee responsebase_fee_change_denominator8 → 42x faster adjustments (±25% vs ±12.5%)
More stable feesbase_fee_change_denominator8 → 162x slower adjustments (±6.25% vs ±12.5%)
Earlier fee increaseselasticity_multiplier2 → 4Fees rise at 25% vs 50% utilization
Stronger spam deterrentmin_gas_priceLow → HighHigher transaction cost floor

Configuration Profiles

{
  "no_base_fee": false,
  "base_fee_change_denominator": 8,      // ±12.5% max per block
  "elasticity_multiplier": 2,            // 50% target utilization
  "enable_height": 0,                    // Active from genesis
  "base_fee": "1000000000000000000000",  // Starting base fee
  "min_gas_price": "1000000000000000000", // Price floor
  "min_gas_multiplier": "500000000000000000" // 0.5 (anti-manipulation)
}
// Behavior: Standard Ethereum, balanced for general use
// 100k gas tx: ~0.1 tokens at base, up to 10x during congestion

Scenario Comparisons

Config5 Blocks10 Blocks10x Time
Ethereum (d=8, e=2)+34%+79%~20 blocks
Stable (d=16, e=2)+16%+34%~40 blocks
Aggressive (d=4, e=4)+101%+304%~8 blocks

Decimal Precision Support

The module supports different token decimal configurations:
DecimalsConversion FactorMin Unit GasExample
610^1210^-12USDC
810^1010^-10BTC-wrapped
1811ETH, most EVM

Configuration In Production

Parameters can be updated through governance proposals (msg server):
// MsgUpdateParams structure
// Source: github.com/cosmos/evm/blob/v0.4.1/proto/cosmos/evm/feemarket/v1/tx.proto
{
  "@type": "/cosmos.evm.feemarket.v1.MsgUpdateParams",
  "authority": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn",
  "params": {
    "no_base_fee": false,
    "base_fee_change_denominator": 16,
    "elasticity_multiplier": 2,
    "enable_height": 100000,
    "base_fee": "1000000000000000000000",
    "min_gas_price": "1000000000000000000",
    "min_gas_multiplier": "500000000000000000"
  }
}
Submit with:
# Submit governance proposal
# Source: github.com/cosmos/evm/blob/v0.4.1/x/feemarket/keeper/msg_server.go#L17-L39
evmd tx gov submit-proposal update-feemarket-params.json \
  --from <key> \
  --deposit 1000000000stake

Best Practices

Parameter Selection by Use Case

Chain TypeDenominatorElasticityMinGasPriceWhy
Testing/Development82Zero/LowQuick iteration
Production General8-162MediumBalance stability and responsiveness
High-Frequency Trading16-321-2LowPredictable fees, high throughput
Enterprise/Private322-3HighMaximum stability, cost predictability
Gaming/Micro-tx4-81Very LowFast adjustments, minimal fees

Block Time Correlation

Faster blocks require higher denominators to maintain stability:
Recommended Denominator = 8 × (6s / YourBlockTime)
Examples:
  • 1s blocks → denominator ≥16 (prevents wild swings)
  • 6s blocks → denominator = 8 (Ethereum standard)
  • 12s blocks → denominator = 4 (can be more responsive)

Monitoring Key Metrics

MetricFormulaHealthyAction if Unhealthy
Fee Volatilityσ(fees)/μ(fees)<20% dailyIncrease denominator
Utilization RategasUsed/maxGas40-60% avgAdjust elasticity
Floor Hit Ratecount(fee==min)\/blocks<10%Lower min_gas_price
Recovery SpeedBlocks to return to baseline20-40Tune denominator

Integration Examples

// Get current base fee from latest block
const block = await provider.getBlock('latest');
const baseFee = block.baseFeePerGas;

// Add buffer for inclusion certainty (20% buffer)
const maxFeePerGas = baseFee * 120n / 100n;
const maxPriorityFeePerGas = ethers.parseUnits("2", "gwei");

// Send EIP-1559 transaction
const tx = await wallet.sendTransaction({
  type: 2,
  maxFeePerGas,
  maxPriorityFeePerGas,
  to: "0x...",
  value: ethers.parseEther("1.0"),
  gasLimit: 21000
});

Interfaces

EVM JSON-RPC

The fee market integrates with standard Ethereum JSON-RPC methods (RPC backend):
eth_gasPrice
string
Returns the current base fee as hex string. In EIP-1559 mode, returns the base fee; in legacy mode, returns the median gas price.
// Request
{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":1}

// Response
{"jsonrpc":"2.0","id":1,"result":"0x3b9aca00"} // 1 gwei in hex
eth_maxPriorityFeePerGas
string
Returns suggested priority fee (tip) per gas. In cosmos/evm with the experimental mempool, transactions are prioritized by effective gas tip (fees), with ties broken by arrival time.
// Request
{"jsonrpc":"2.0","method":"eth_maxPriorityFeePerGas","params":[],"id":1}

// Response
{"jsonrpc":"2.0","id":1,"result":"0x77359400"} // Suggested tip in wei
eth_feeHistory
object
Returns base fee and gas utilization history for a range of blocks.
// Request
{
  "jsonrpc":"2.0",
  "method":"eth_feeHistory",
  "params":["0x5", "latest", [25, 50, 75]],
  "id":1
}

// Response
{
  "jsonrpc":"2.0",
  "id":1,
  "result":{
    "baseFeePerGas": [
      "0x3b9aca00",
      "0x3c9aca00",
      "0x3d9aca00",
      "0x3e9aca00",
      "0x3f9aca00"
    ],
    "gasUsedRatio": [0.5, 0.55, 0.6, 0.48, 0.52],
    "oldestBlock": "0x1234",
    "reward": [
      ["0x0", "0x0", "0x0"],
      ["0x0", "0x0", "0x0"],
      ["0x0", "0x0", "0x0"],
      ["0x0", "0x0", "0x0"],
      ["0x0", "0x0", "0x0"]
    ]
  }
}
eth_getBlockByNumber
object
Block responses include baseFeePerGas field when EIP-1559 is enabled.
{
  "jsonrpc":"2.0",
  "id":1,
  "result":{
    "number": "0x1234",
    "hash": "0x...",
    "baseFeePerGas": "0x3b9aca00", // Base fee for this block
    // ... other block fields
  }
}

Transaction Types

The fee market supports both legacy and EIP-1559 transaction types (types):
{
  "type": "0x0",
  "gasPrice": "0x3b9aca00",  // Must be >= current base fee
  "gas": "0x5208",
  "to": "0x...",
  "value": "0x...",
  "data": "0x..."
}

CLI

# Query module parameters
# Source: github.com/cosmos/evm/blob/v0.4.1/x/feemarket/client/cli/query.go
evmd query feemarket params

gRPC

// Request all module parameters
// Proto: github.com/cosmos/evm/blob/v0.4.1/proto/cosmos/evm/feemarket/v1/query.proto
grpcurl -plaintext localhost:9090 feemarket.Query/Params

// Response
{
  "params": {
    "no_base_fee": false,
    "base_fee_change_denominator": 8,
    "elasticity_multiplier": 2,
    "enable_height": 0,
    "base_fee": "1000000000000000000000",
    "min_gas_price": "1000000000000000000",
    "min_gas_multiplier": "500000000000000000"
  }
}

REST

# REST endpoint for parameters
# Proto: github.com/cosmos/evm/blob/v0.4.1/proto/cosmos/evm/feemarket/v1/query.proto
GET /cosmos/feemarket/v1/params

// Response
{
  "params": {
    "no_base_fee": false,
    "base_fee_change_denominator": 8,
    "elasticity_multiplier": 2,
    "enable_height": 0,
    "base_fee": "1000000000000000000000",
    "min_gas_price": "1000000000000000000",
    "min_gas_multiplier": "500000000000000000"
  }
}

Technical Implementation

State

The module maintains the following state (genesis proto):

State Objects

State ObjectDescriptionKeyValueStore
BlockGasWantedGas wanted in the current block[]byte{1}[]byte{uint64}Transient
BaseFeeCurrent base feeParams.BaseFeesdk.DecKV
ParamsModule parameters[]byte{0x00}ParamsKV

Genesis State

type GenesisState struct {
    Params Params
    BaseFee sdk.Dec
}

Begin Block

At the beginning of each block, the module calculates and sets the new base fee (source):
func (k Keeper) BeginBlock(ctx sdk.Context) error {
    baseFee := k.CalculateBaseFee(ctx)

    // Skip if base fee is nil (not enabled)
    if baseFee.IsNil() {
        return nil
    }

    // Update the base fee in state
    k.SetBaseFee(ctx, baseFee)

    // Emit event with new base fee
    ctx.EventManager().EmitEvent(
        sdk.NewEvent(
            "fee_market",
            sdk.NewAttribute("base_fee", baseFee.String()),
        ),
    )
    return nil
}

End Block

At the end of each block, the module updates the gas wanted for base fee calculation (source):
func (k Keeper) EndBlock(ctx sdk.Context) error {
    gasWanted := k.GetTransientGasWanted(ctx)
    gasUsed := ctx.BlockGasMeter().GasConsumedToLimit()

    // Apply MinGasMultiplier to prevent manipulation
    // gasWanted = max(gasWanted * MinGasMultiplier, gasUsed)
    minGasMultiplier := k.GetParams(ctx).MinGasMultiplier
    limitedGasWanted := NewDec(gasWanted).Mul(minGasMultiplier)
    updatedGasWanted := MaxDec(limitedGasWanted, NewDec(gasUsed)).TruncateInt()

    // Store for next block's base fee calculation
    k.SetBlockGasWanted(ctx, updatedGasWanted)

    ctx.EventManager().EmitEvent(
        sdk.NewEvent(
            "block_gas",
            sdk.NewAttribute("height", fmt.Sprintf("%d", ctx.BlockHeight())),
            sdk.NewAttribute("amount", fmt.Sprintf("%d", updatedGasWanted)),
        ),
    )
    return nil
}

Base Fee Calculation Algorithm

The calculation follows the EIP-1559 specification with Cosmos SDK adaptations (source, utils):

Keeper

The keeper manages fee market state and calculations (source):
MethodDescriptionUsage
GetBaseFee() / SetBaseFee()Current base feeRead/update during block processing
GetParams() / SetParams()Module parametersGovernance updates
GetBlockGasWanted() / SetBlockGasWanted()Gas trackingBase fee calculation
CalculateBaseFee()Compute next base feeCalled in BeginBlock
The module also implements PostTxProcessing hooks for EVM transaction processing (source).

Events

The module emits the following events (types):

Fee Market Block Fees

Attribute KeyAttribute Value
heightCurrent block height
base_feeNew base fee
gas_wantedTotal gas wanted in block
gas_usedTotal gas used in block
Example:
{
  "type": "fee_market_block_fees",
  "attributes": [
    {"key": "height", "value": "12345"},
    {"key": "base_fee", "value": "1000000000"},
    {"key": "gas_wanted", "value": "5000000"},
    {"key": "gas_used", "value": "4800000"}
  ]
}

AnteHandlers

The module integrates with EVM transactions through the EVMMonoDecorator, which performs all fee-related validations in a single pass (source):

EVMMonoDecorator

The primary ante handler that validates and processes EVM transaction fees (mono_decorator.go):

Fee Validation Functions

CheckMempoolFee
Validates transaction fees against the local mempool minimum (source):
CheckGlobalFee
Enforces the chain-wide minimum gas price set via governance (source):
CheckGasWanted
Tracks cumulative gas wanted for base fee calculation (source):

Module Distinctions

cosmos/evm vs Standard Cosmos SDK

This fee market module from cosmos/evm differs from standard Cosmos SDK fee handling:
AspectStandard Cosmos SDKcosmos/evm Feemarket
Fee ModelStatic, validator-configured min gas pricesDynamic EIP-1559 base fee
Price DiscoveryManual adjustment by validatorsAutomatic based on utilization
Transaction TypesCosmos SDK Tx onlyBoth Cosmos & Ethereum txs
Decimal HandlingChain-specific precision18-decimal EVM compatibility
State StorageNot trackedBase fee in state, gas in transient store
Consensus ImpactNo consensus on feesBase fee part of consensus

Key Integration Points

The module integrates with EVM through:
  • AnteHandlers: Custom decorators for EVM transaction validation (source)
  • Hooks: PostTxProcessing for EVM state updates (source)
  • RPC: Ethereum JSON-RPC methods for fee queries (source)

References

Source Code

Specifications

Tools & Libraries