Skip to main content

Try it Live

Run Chain examples in the interactive playground

Network Comparison

Comprehensive comparison of gas fees, transaction costs, and network characteristics across Ethereum networks.

Network Overview

Mainnet vs L2 vs Testnet

NetworkTypeAvg Gas PriceTransfer CostSwap CostStatus
EthereumMainnet40-100 Gwei$2-5$50-200Live
ArbitrumL20.1 Gwei$0.01$0.50-2Live
OptimismL20.1 Gwei$0.01$0.50-2Live
BaseL20.1 Gwei$0.01$0.50-2Live
PolygonSidechain20-50 Gwei$0.01-0.05$0.20-1Live
SepoliaTestnet1-5 GweiFree (faucet)Free (faucet)Test
HoleskyTestnet1-5 GweiFree (faucet)Free (faucet)Test
Costs assume ETH = $2,000 and typical operation sizes

Gas Price Breakdown

How Gas Works on Different Networks

import { Chain } from 'tevm'
import * as Gwei from 'tevm/Gwei'
import * as Wei from 'tevm/Wei'
import * as Uint from 'tevm/Uint'

const mainnet = Chain.fromId(1)!

// EIP-1559: baseFee + priorityFee
const baseFee = Gwei(30n)     // Set by protocol
const priorityFee = Gwei(2n)  // User sets (tip)
const maxFee = Gwei(50n)      // User sets max

// Cost for 21,000 gas transfer
const effectivePrice = Uint.plus(
  Gwei.toU256(baseFee),
  Gwei.toU256(priorityFee)
)

const costWei = Uint.times(effectivePrice, Uint(21_000n))
const costGwei = Uint.dividedBy(costWei, Uint(1_000_000_000n))
const costEther = Wei.toEther(Wei(costWei))

console.log(`Network: ${mainnet.name}`)
console.log(`Cost: ${costGwei} Gwei = ${costEther} ETH`)
console.log('Features:')
console.log('- EIP-1559 dynamic pricing')
console.log('- Base fee burns')
console.log('- Priority fee for miners')
Cost Characteristics:
  • Variable gas prices (20-300+ Gwei during congestion)
  • Base fee automatically adjusts
  • Longer confirmation times during high load
  • Higher security (full validator set)

Real Transaction Costs

Transfer (21,000 gas)

import { Chain } from 'tevm'
import * as Gwei from 'tevm/Gwei'
import * as Wei from 'tevm/Wei'
import * as Uint from 'tevm/Uint'

function calculateTransferCost(
  chainId: number,
  gasPriceGwei: bigint
): { wei: bigint; eth: string; usd: string } | null {
  const chain = Chain.fromId(chainId)
  if (!chain) return null

  const gasPriceWei = Gwei.toWei(Gwei(gasPriceGwei))
  const costWei = Uint.times(gasPriceWei, Uint(21_000n))
  const costEth = Number(costWei) / 1e18
  const costUsd = costEth * 2000  // Assuming $2000/ETH

  return {
    wei: costWei,
    eth: costEth.toFixed(6),
    usd: `$${(costEth * 2000).toFixed(2)}`
  }
}

const networks = [
  { id: 1, price: 50n, name: 'Ethereum Mainnet' },
  { id: 42161, price: 1n, name: 'Arbitrum One' },
  { id: 10, price: 1n, name: 'Optimism' },
  { id: 8453, price: 1n, name: 'Base' },
  { id: 137, price: 30n, name: 'Polygon' },
  { id: 11155111, price: 1n, name: 'Sepolia (testnet)' }
]

console.log('Transfer Cost Comparison (21,000 gas):')
console.log('─'.repeat(60))

networks.forEach(({ id, price, name }) => {
  const cost = calculateTransferCost(id, price)
  if (cost) {
    console.log(`${name.padEnd(25)} ${cost.eth.padEnd(12)} ETH = ${cost.usd}`)
  }
})
Output:
Transfer Cost Comparison (21,000 gas):
────────────────────────────────────────────────────
Ethereum Mainnet         0.00105    ETH = $2.10
Arbitrum One             0.000021   ETH = $0.042
Optimism                 0.000021   ETH = $0.042
Base                     0.000021   ETH = $0.042
Polygon                  0.00063    ETH = $1.26
Sepolia (testnet)        0.000021   ETH = Free!

Complex Swap (150,000 gas)

import { Chain } from 'tevm'
import * as Gwei from 'tevm/Gwei'
import * as Wei from 'tevm/Wei'
import * as Uint from 'tevm/Uint'

function calculateSwapCost(
  chainId: number,
  gasPriceGwei: bigint
): { eth: string; usd: string } | null {
  const chain = Chain.fromId(chainId)
  if (!chain) return null

  const gasPriceWei = Gwei.toWei(Gwei(gasPriceGwei))
  const costWei = Uint.times(gasPriceWei, Uint(150_000n))
  const costEth = Number(costWei) / 1e18
  const costUsd = costEth * 2000

  return {
    eth: costEth.toFixed(5),
    usd: `$${costUsd.toFixed(2)}`
  }
}

const networks = [
  { id: 1, price: 50n, name: 'Ethereum Mainnet' },
  { id: 42161, price: 1n, name: 'Arbitrum One' },
  { id: 10, price: 1n, name: 'Optimism' },
  { id: 8453, price: 1n, name: 'Base' },
  { id: 137, price: 30n, name: 'Polygon' }
]

console.log('Swap Cost Comparison (150,000 gas):')
console.log('─'.repeat(60))

networks.forEach(({ id, price, name }) => {
  const cost = calculateSwapCost(id, price)
  if (cost) {
    console.log(`${name.padEnd(25)} ${cost.eth.padEnd(12)} ETH = ${cost.usd}`)
  }
})
Output:
Swap Cost Comparison (150,000 gas):
────────────────────────────────────────────────────
Ethereum Mainnet         0.015      ETH = $30.00
Arbitrum One             0.00015    ETH = $0.30
Optimism                 0.00015    ETH = $0.30
Base                     0.00015    ETH = $0.30
Polygon                  0.0045     ETH = $9.00

Network Selection Guide

When to use each network:

Use when:
  • Real financial transactions
  • Maximum security needed
  • Settlement certainty required
  • Large value transfers
Avoid when:
  • User experience critical (high gas)
  • Frequent micro-transactions
  • Testing/development
Best for:
  • Loans, staking, large transfers
  • Custody, bridges
  • Governance

Network Configuration Lookup

import { Chain } from 'tevm'

// Lookup network by chain ID
const networks = [1, 10, 42161, 8453, 137, 11155111]

networks.forEach(chainId => {
  const chain = Chain.fromId(chainId)
  if (!chain) return

  console.log(`\n=== ${chain.name} ===`)
  console.log(`Chain ID: ${chain.chainId}`)
  console.log(`Symbol: ${chain.nativeCurrency.symbol}`)
  console.log(`Decimals: ${chain.nativeCurrency.decimals}`)
  console.log(`RPC: ${chain.rpc[0]}`)

  if (chain.explorers?.[0]) {
    console.log(`Explorer: ${chain.explorers[0].name}`)
    console.log(`Explorer URL: ${chain.explorers[0].url}`)
  }
})

Fee Estimation Across Networks

import { Chain } from 'tevm'
import * as Gwei from 'tevm/Gwei'
import * as Wei from 'tevm/Wei'
import * as Uint from 'tevm/Uint'

interface FeeEstimate {
  network: string
  baseGasPrice: Gwei.Type
  transferCost: { eth: string; gwei: string }
  swapCost: { eth: string; gwei: string }
}

function estimateFees(
  chainId: number,
  baseGasPrice: bigint
): FeeEstimate | null {
  const chain = Chain.fromId(chainId)
  if (!chain) return null

  const calculateCost = (gas: bigint) => {
    const costWei = Uint.times(
      Gwei.toWei(Gwei(baseGasPrice)),
      Uint(gas)
    )
    return {
      eth: (Number(costWei) / 1e18).toFixed(6),
      gwei: Uint.dividedBy(costWei, Uint(1_000_000_000n)).toString()
    }
  }

  return {
    network: chain.name,
    baseGasPrice: Gwei(baseGasPrice),
    transferCost: calculateCost(21_000n),
    swapCost: calculateCost(150_000n)
  }
}

// Get all major networks
const networks = [
  { id: 1, price: 50n },     // Mainnet
  { id: 42161, price: 1n },  // Arbitrum
  { id: 10, price: 1n },     // Optimism
  { id: 8453, price: 1n },   // Base
  { id: 137, price: 30n }    // Polygon
]

networks.forEach(({ id, price }) => {
  const fees = estimateFees(id, price)
  if (fees) {
    console.log(`${fees.network}:`)
    console.log(`  Transfer: ${fees.transferCost.eth} ETH`)
    console.log(`  Swap: ${fees.swapCost.eth} ETH`)
  }
})

Migration Between Networks

Bridging ETH

When moving funds between Ethereum and L2s:
import { Chain } from 'tevm'

const mainnet = Chain.fromId(1)!
const arbitrum = Chain.fromId(42161)!
const optimism = Chain.fromId(10)!

// Bridging requires:
// 1. Approval on source chain (Ethereum)
// 2. Bridge contract interaction
// 3. Waiting for L2 confirmation

// Costs:
// - Ethereum approval + bridge call: ~200k gas = $2-5
// - L2 finalization: ~100-200k gas = $0.10-0.30
// Total: ~$2.30-5.30 for bridge in

console.log('Bridge costs (ETH → L2):')
console.log(`Approval: 45k gas @ 50 gwei = 0.00225 ETH`)
console.log(`Bridge TX: 200k gas @ 50 gwei = 0.01 ETH`)
console.log(`L2 Finalization: 100k gas @ 1 gwei = 0.0001 ETH`)
console.log(`Total: ~0.01225 ETH (~$24.50)`)

// Withdrawal back (L2 → Ethereum)
console.log('\nWithdrawal costs (L2 → Ethereum):')
console.log(`L2 initiate: 100k gas @ 1 gwei = 0.0001 ETH`)
console.log(`Mainnet finalize: 200k gas @ 50 gwei = 0.01 ETH`)
console.log(`Wait time: 7 days (fraud proof)`)
console.log(`Total: ~0.0101 ETH (~$20.20)`)