💶 Fee Estimation

The Fee submodule allows developers to interact with various blockchain networks. It specifically provides functionalities related to retrieving gas fees.

Tatum's Fee Estimation simplifies the process of retrieving current gas fees for blockchain networks. Gas fees represent the cost of executing transactions, and this tool allows developers to provide better transparency and user experience within decentralized applications.

Example: Fetching Ethereum Gas Fees

curl --location 'https://api.tatum.io/v3/blockchain/fee/ETH' \
--header 'x-api-key: {YOUR_API_KEY}'
//response:
{
    "slow": 7434177604,
    "medium": 7434177604,
    "fast": 7434177604,
    "baseFee": 7084441738,
    "time": "2024-05-06T09:33:41.906Z",
    "block": 19810178
}
import { TatumSDK, Network, ApiVersion } from "@tatumio/tatum";

// Initialize the Tatum SDK with the desired network and API version
const tatum = await TatumSDK.init({ network: Network.ETHEREUM, version: ApiVersion.V1 });

// Fetch the current gas fee
const fee = await tatum.fee.getCurrentFee();

// Display the fetched fee in console
console.log(fee.data.gasPrice.fast);
});

📘

API Reference

Use Cases

The Tatum Fee Submodule offers several use cases for developers working with blockchain networks. Some potential applications include:

  1. Transaction Cost Estimation:
    Retrieve current fees to calculate approximate transaction costs, helping users optimize parameters for their transactions.
  2. User-Friendly Fee Display:
    Integrate real-time fee updates into applications for better transparency, improving user engagement.
  3. Gas Fee Comparison:
    Compare fees across networks to help users choose the most cost-effective blockchain for their needs.

Challenges in Accurate Fee Estimation

  1. Dynamic Fee Markets:
    Gas fees fluctuate based on network demand and congestion.
  2. Lack of Standardization:
    Different networks have unique fee models and measurement units.
  3. Network-Specific Implementations:
    Each network’s APIs and nodes have specific requirements, adding complexity.

Tatum simplifies these challenges with a unified interface, allowing developers to integrate gas fee functionalities without dealing with individual network complexities.

Tatum's Fee Monitoring System

For Bitcoin and Ethereum mainnets, Tatum uses its proprietary system to closely monitor and estimate fees.

For all other networks, fee estimates are sourced directly from the nodes, which may occasionally be inaccurate due to network-specific variables beyond our control.