🔧Fee Market Module with Dynamic Fees

This guide explains how to use the feemarket module to implement dynamic fee calculation for standard Cosmos SDK transactions on the cheqd network. The feemarket module provides real-time gas pricing based on network congestion and demand.

Note: Identity transactions (DIDs and DID-Linked Resources) have their own fixed pricing model and are not affected by the feemarket module's dynamic pricing.

Understanding Dynamic Fees

Dynamic fees adjust transaction costs based on network conditions:

  • High Network Activity: Gas prices increase to prioritize transactions

  • Low Network Activity: Gas prices decrease to reduce transaction costs

  • Real-time Pricing: Prices update continuously based on network demand

Gas Price Endpoints

You can fetch current gas prices directly from the cheqd network APIs:

Mainnet

GET https://api.cheqd.net/feemarket/v1/gas_price/ncheq

Testnet

GET https://api.cheqd.network/feemarket/v1/gas_price/ncheq

API Response Format

The API returns a decimal value that needs to be converted:

Interpretation: 0.500000000000000000 × 10^4 = 5000ncheq

The price represents the cost per unit of gas in ncheq (nano CHEQ tokens).

SDK Implementation

Prerequisites

Ensure your SDK includes the feemarket module:

Fetching Dynamic Gas Prices

Standard Cosmos SDK Transactions with Dynamic Fees

Token Transfer

Staking Delegation

Claiming Staking Rewards

Governance Voting

Fee Optimization Strategies

Gas Estimation

Fee Comparison

Advanced Usage

Batch Transaction Optimization

Fee Market Monitoring

Best Practices

1. Gas Estimation

  • Always simulate transactions before broadcasting

  • Add 10-20% buffer to gas estimates

  • Use batch transactions to optimize gas usage

2. Fee Management

  • Monitor network congestion regularly

  • Consider fee abstraction for predictable costs

  • Use dynamic pricing during low-congestion periods

3. Error Handling

4. Performance Tips

  • Cache gas prices for short periods (30-60 seconds)

  • Use WebSocket connections for real-time price updates

  • Implement circuit breakers for high-fee scenarios

Troubleshooting

Common Issues

  1. High Gas Fees

    • Check network congestion

    • Consider using fee abstraction

    • Wait for off-peak hours

  2. Transaction Failures

    • Increase gas limit

    • Verify account balance

    • Check message formatting

  3. API Failures

    • Implement fallback pricing

    • Use multiple RPC endpoints

    • Handle network timeouts

Error Codes

Next Steps

Getting Help

If you encounter issues with dynamic fees:

Last updated

Was this helpful?