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 + priorityFeeconst baseFee = Gwei(30n) // Set by protocolconst priorityFee = Gwei(2n) // User sets (tip)const maxFee = Gwei(50n) // User sets max// Cost for 21,000 gas transferconst 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)
import { Chain } from 'tevm'import * as Gwei from 'tevm/Gwei'import * as Wei from 'tevm/Wei'import * as Uint from 'tevm/Uint'const arbitrum = Chain.fromId(42161)!// L2 gas prices much lowerconst gasPrice = Gwei(1n) // Usually 0.1-1 Gwei// Transfer costs very littleconst costWei = Uint.times( Gwei.toWei(gasPrice), Uint(21_000n))const costGwei = Uint.dividedBy(costWei, Uint(1_000_000_000n))const costEther = Wei.toEther(Wei(costWei))console.log(`Network: ${arbitrum.name}`)console.log(`Cost: ${costGwei} Gwei = ${costEther} ETH (very cheap!)`)console.log('Features:')console.log('- Optimistic rollup')console.log('- High throughput (4500+ TPS)')console.log('- Fraud proof settlement')console.log('- Native ETH (same as mainnet)')
Cost Characteristics:
Ultra-low gas prices (0.1-1 Gwei)
1-7 day withdrawal to mainnet
Near-instant local confirmation
Near-mainnet security via rollup
import { Chain } from 'tevm'import * as Gwei from 'tevm/Gwei'import * as Wei from 'tevm/Wei'import * as Uint from 'tevm/Uint'const polygon = Chain.fromId(137)!// Polygon has low but higher than L2sconst gasPrice = Gwei(30n) // 20-100 Gwei rangeconst costWei = Uint.times( Gwei.toWei(gasPrice), Uint(21_000n))const costGwei = Uint.dividedBy(costWei, Uint(1_000_000_000n))const costEther = Wei.toEther(Wei(costWei))// But uses MATIC, not ETHconsole.log(`Network: ${polygon.name}`)console.log(`Native currency: ${polygon.nativeCurrency.symbol}`)console.log(`Cost: ${costGwei} Gwei = ${costEther} ETH`)console.log('Features:')console.log('- PoS sidechain')console.log('- EVM compatible')console.log('- Separate validation')console.log('- Bridge required for mainnet')
Cost Characteristics:
Low gas prices (20-100 MATIC)
High throughput
Separate validator set (lower security)
Bridge delays for withdrawal
import { Chain } from 'tevm'const sepolia = Chain.fromId(11155111)!// Testnet prices irrelevant (free from faucets)console.log(`Network: ${sepolia.name}`)console.log(`Type: ${sepolia.chain}`)console.log(`Native currency: ${sepolia.nativeCurrency.symbol}`)console.log('Features:')console.log('- EIP-1559 like mainnet')console.log('- Free funds from faucet')console.log('- No real value')console.log('- For development only')
Transfer Cost Comparison (21,000 gas):────────────────────────────────────────────────────Ethereum Mainnet 0.00105 ETH = $2.10Arbitrum One 0.000021 ETH = $0.042Optimism 0.000021 ETH = $0.042Base 0.000021 ETH = $0.042Polygon 0.00063 ETH = $1.26Sepolia (testnet) 0.000021 ETH = Free!
Swap Cost Comparison (150,000 gas):────────────────────────────────────────────────────Ethereum Mainnet 0.015 ETH = $30.00Arbitrum One 0.00015 ETH = $0.30Optimism 0.00015 ETH = $0.30Base 0.00015 ETH = $0.30Polygon 0.0045 ETH = $9.00