# Ethereum & Layer 2 Gas Fees: Transaction Cost by Chain (`scrapemint/gas-fees-by-chain`) Actor

Keyless live gas fees for Ethereum, Base, Arbitrum, Optimism, Polygon and BNB Chain, converted into the dollar cost of what users actually do: send coins, send tokens, swap or mint. Includes the layer 2 data fee that a plain gas price leaves out.

- **URL**: https://apify.com/scrapemint/gas-fees-by-chain.md
- **Developed by:** [Ken M](https://apify.com/scrapemint) (community)
- **Categories:** Business, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$4.00 / 1,000 gas fee rows

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Ethereum & Layer 2 Gas Fees: Transaction Cost by Chain

What a transaction actually costs right now on **Ethereum, Base, Arbitrum, Optimism, Polygon and BNB Chain** — not just a gas price in gwei, but the **cost in dollars of the things users actually do**: send the native coin, send a token, swap on a DEX, mint an NFT.

Reads public JSON-RPC nodes directly. No API key, no account, no browser.

### Modes

- **Gas** - one row per chain: gas price, base fee, the priority fee at the 10th, 50th and 90th percentile, how full recent blocks are, and the dollar cost of four standard actions.
- **Actions** - one row per chain per action, ranked cheapest first, with how many times the cheapest chain each one costs.
- **History** - one row per recent block: base fee and block fullness.

### Example output

```json
{
  "mode": "actions",
  "action": "transfer",
  "chain": "Base",
  "isLayer2": true,
  "settlementLayer": "Ethereum",
  "executionCostNative": 0.000000126,
  "l1DataFeeNative": 0.000000005079,
  "totalCostUsd": 0.00025,
  "costRankAmongChains": 2,
  "timesCheapestChainCost": 4.59,
  "l1DataFeeHandling": "L1 data fee priced by the chain own gas oracle and added"
}
```

### The part most gas trackers get wrong

**A layer 2's real cost is not its gas price.** Base and Optimism charge a cheap execution fee plus a fee for posting your transaction data to Ethereum, and the second part usually dominates. In a live run today, a Base transfer cost $0.00025, of which the execution component was worth about $0.0000002 — **quoting the gas price alone understates the true cost by roughly a thousand times.**

This actor prices that L1 component through each chain's own on-chain gas oracle and adds it, and every row says which method was used:

- **Base and Optimism** - L1 data fee read from the gas oracle and included.
- **Arbitrum** - bills its L1 cost as **extra gas units** rather than a separate fee, so a standard gas figure does not capture it. The row says so, and reports the execution estimate rather than inventing a number that looks complete.
- **Ethereum, Polygon, BNB Chain** - settle their own transactions, so there is nothing extra to add.

### Other things worth knowing

- **Public RPC nodes answer 403 to a request with no User-Agent.** That is a missing header, not a block, and it is the sort of thing that reads as "this endpoint is dead" if you do not check.
- **A JSON-RPC error arrives inside an HTTP 200 response**, so the status code alone never means success. Every call checks the envelope.
- **Each chain has more than one endpoint here** and calls rotate through them, so one node rate limiting does not fail the run. The endpoint actually used ships on every row.
- **Polygon's token was renamed from MATIC to POL.** The old ticker no longer exists on the price venue, so asking for it silently prices the chain at nothing. It is quoted as POL.
- **`baseFeePerGas` returns one more entry than `gasUsedRatio`** — the extra entry is the *next* block, which has no usage yet. Pairing them by index without allowing for that shifts every reading by one block.
- **Gas units are representative, not a quote.** A swap is priced at 150,000 gas because that is typical; your specific swap may differ. The assumed figure ships on every actions row so you can substitute your own.
- Where a native token price cannot be fetched, dollar costs are null and **native costs are still reported**, rather than a chain silently vanishing from the comparison.

### Who this is for

- **Wallet and dapp developers** quoting costs to users, or deciding which chain to deploy on.
- **Traders** timing transactions around congestion, and anyone comparing bridging destinations by cost.
- **Analysts** tracking the economics of layer 2s against the chain they settle to.

### Pricing

**$0.004 per row.** The first 2 rows of every run are free, and note rows (an unknown chain, an unknown action, a chain that did not respond) are never charged.

A full snapshot of all six chains is 6 rows, or **$0.024**. Every action on every chain is 24 rows, or **$0.096**. This is built to be scheduled: fees move minute to minute, and the interesting readings are the busy ones.

### Related actors

- **Bitcoin Network Data** - the same question for Bitcoin: fees, mempool and difficulty.
- **Crypto Order Book Depth** - liquidity and slippage across exchanges.

### How to run it via API

```bash
curl -X POST "https://api.apify.com/v2/acts/scrapemint~gas-fees-by-chain/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"mode":"actions","chains":["ethereum","base","arbitrum"],"actions":["swap"]}'
```

Fee data from public JSON-RPC nodes. Native token prices from OKX.

# Actor input Schema

## `mode` (type: `string`):

gas = one row per chain with fee levels, congestion and the cost of four standard actions. actions = one row per chain per action, ranked cheapest first. history = recent blocks with base fee and how full they were.

## `chains` (type: `array`):

ethereum, base, arbitrum, optimism, polygon, bsc. Empty returns all six.

## `actions` (type: `array`):

transfer (send the native coin), token\_transfer (send an ERC20), swap (trade on a DEX), nft\_mint. Gas units are representative of each kind of transaction, not a quote for a specific one.

## `blockCount` (type: `integer`):

History mode. Recent blocks per chain, up to 10 per request from the node.

## `maxRows` (type: `integer`):

Cap on rows returned. Controls total cost.

## Actor input object example

```json
{
  "mode": "gas",
  "chains": [
    "ethereum",
    "base",
    "arbitrum",
    "optimism",
    "polygon",
    "bsc"
  ],
  "actions": [
    "transfer",
    "token_transfer",
    "swap",
    "nft_mint"
  ],
  "blockCount": 10,
  "maxRows": 200
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "chains": [
        "ethereum",
        "base",
        "arbitrum",
        "optimism",
        "polygon",
        "bsc"
    ],
    "actions": [
        "transfer",
        "token_transfer",
        "swap",
        "nft_mint"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapemint/gas-fees-by-chain").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "chains": [
        "ethereum",
        "base",
        "arbitrum",
        "optimism",
        "polygon",
        "bsc",
    ],
    "actions": [
        "transfer",
        "token_transfer",
        "swap",
        "nft_mint",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("scrapemint/gas-fees-by-chain").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "chains": [
    "ethereum",
    "base",
    "arbitrum",
    "optimism",
    "polygon",
    "bsc"
  ],
  "actions": [
    "transfer",
    "token_transfer",
    "swap",
    "nft_mint"
  ]
}' |
apify call scrapemint/gas-fees-by-chain --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrapemint/gas-fees-by-chain"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/X2HsPE2YIfTNTkPpy/builds/69nLak7Hz7ac55AgF/openapi.json
