# Estimate gas fees

Transaction fees (or "gas fees") can vary significantly depending on network activity, so having a reliable estimation method is crucial for a smooth user experiences.

{% hint style="warning" %}
To ensure that your transaction doesn't remain in "pending" status for too long, you should include enough to cover the fees:

* Minimum gas fee: 2,501 Gwei.
* Minimum priority fee: 1 Gwei.
  {% endhint %}

## What does it mean for Chiliz Chain developers?

Just like with any blockchain, you must pay gas for every transaction on Chiliz Chain.&#x20;

The key is to balance cost-effectiveness with timely confirmations to avoid failing or delayed transactions. Keeping your gas estimates up to date helps prevent both overpaying and underpaying.

## How to do it natively

If you want to keep it *vanilla*, you can rely on a [cURL](https://curl.se/) request to a [Chiliz Chain RPC server](https://docs.chiliz.com/develop/basics/connect-to-chiliz-chain/connect-using-rpc). See here: [#how-to-get-the-current-gas-price](https://docs.chiliz.com/basics/tips-and-tricks#how-to-get-the-current-gas-price "mention").

## How to do it through an explorer API

Both [Chiliscan](https://chiliscan.com/) and [Chiliz Block Explorer](https://scan.chiliz.com/) offer APIs allowing you to get the current gas price for Chiliz Chain.

{% hint style="warning" %}
You need an API key in order to interact with the available API methods/endpoints.
{% endhint %}

{% hint style="info" %}
Both explorer also have a "Gas tracker" page:

* <https://chiliscan.com/insight/leaderboard/gas-tracker>
* <https://scan.chiliz.com/gas-tracker>
  {% endhint %}

### Using Chiliscan's API

The Chiliscan API provides the `avg-gas-price` method for that purpose:

{% embed url="<https://chiliscan.com/documentation/api/swagger>" %}

{% code overflow="wrap" %}

```bash
curl -X 'GET' \
  'https://api.routescan.io/v2/network/mainnet/evm/88888/aggregations/avg-gas-price?apikey=YourApiKeyToken' \
  -H 'accept: application/json'
```

{% endcode %}

... which will return a JSON string with the current value.

### Using Chiliz Block Explorer's API

The Chiliz Block Explorer API has the stats endpoint which provides that information:

{% embed url="<https://scan.chiliz.com/api-docs?tab=rest_api>" %}

```bash
curl -X 'GET' \
  'https://scan-api.chiliz.com/api/v2/stats' \
  -H 'accept: application/json'
```

The endpoint returns which includes gas price information. For example:

```json
{
  "total_blocks": "508700",
  "total_addresses": "982340",
  "total_transactions": "1699427",
  "average_block_time": 25000,
  "coin_price": "0.00254957",
  "total_gas_used": "0",
  "transactions_today": "622",
  "gas_used_today": "49063630",
  "gas_prices": {
    "average": 10,
    "fast": 10,
    "slow": 10
  },
  "static_gas_price": "10.1",
  "market_cap": "420471.10604559750644",
  "network_utilization_percentage": 40.2142
}
```

You'll want to use this section (prices are in Gwei):

```json
"gas_prices": {
    "average": 10,
    "fast": 10,
    "slow": 10
  },
```

{% hint style="info" %}

* `average` balances a moderate cost with reliable inclusion in the next few blocks.
* `fast` pays the highest premium to incentivize validators to prioritize your transaction immediately, ensuring the quickest possible confirmation for urgent needs.
* `slow` offers the lowest fee but carries the risk of your transaction remaining pending if network congestion increases.
  {% endhint %}

## How to do it using Blocknative?

[Blocknative](https://www.blocknative.com/) builds infrastructure to monitor and manage the complexity of transacting on public blockchain networks.&#x20;

Blocknative’s [Gas API](https://docs.blocknative.com/gas-prediction/gas-platform) offers a reliable, real-time approach to retrieving gas prices.

### Step 1: Get a key

To use Blocknative's Gas API in your project, you will need an API Key.

You will need to [join the Gas Network first](https://www.gas.network/), which will give you access to your own API key.

### Step 2: Implement the call to the Gas API

Once you have an API key, you can request fee estimation for Chiliz.

{% hint style="info" %}
Remember that the chain ID for Chiliz Chain Mainnet is `88888`.
{% endhint %}

The simplest way is to call on the API via a REST request. For instance, via command line:

{% code overflow="wrap" %}

```bash
curl -H "Authorization: your-apikey-here" \
  'https://api.blocknative.com/gasprices/blockprices?chainid=88888'
```

{% endcode %}

Learn more in [the Blocknative documentation](https://docs.blocknative.com/gas-prediction/gas-platform).
