What gas is
Every transaction asks validators to run code and store data. Gas is the unit that measures that work, and the gas fee is what you pay for it. It also keeps the network usable: spamming it with useless transactions would cost real money.
The amount of work depends on what the transaction does. A plain ETH transfer always uses 21,000 gas units. A token swap reads and updates pool contracts, moves tokens and may hop through several pools, so it uses far more. Adjust the gas price and ETH price below to turn units into dollars.
Typical gas used per action (approximate)
Cost = gas used x gas price. Example values, not live prices; on Ethereum mainnet gas is paid in ETH.
Show data as a table
| Action | Gas used | Cost |
|---|---|---|
| ETH transfer | 21,000 | $0.06 |
| ERC-20 transfer | ~50,000 | $0.15 |
| ERC-20 approve | ~46,000 | $0.14 |
| Simple swap (single pool) | ~120,000 | $0.36 |
| Aggregator swap (multi-hop) | ~200,000 | $0.60 |
| Cross-chain deposit | ~150,000 | $0.45 |
How the price is set on Ethereum
Since the London upgrade in 2021, Ethereum prices gas with EIP-1559. The price per unit has two parts, and you set two caps that protect you from paying more than you meant to.
| Part | Set by | Goes to | What to know |
|---|---|---|---|
| Base fee | The protocol, block by block | Burned | Rises when blocks are more than half full, falls when they are less, by up to 12.5% per block. |
| Priority fee (tip) | You, usually suggested by the wallet | The validator | A small tip gets you into the next block; a bigger one only helps when blocks are full. |
| Max fee per gas | You | Cap only | The most you accept per unit. Anything above base fee plus tip is not charged. |
| Gas limit | Wallet estimate | Cap only | The most units the transaction may use. Unused gas is not charged. |
What you actually pay is gas used × (base fee + priority fee). If the base fee drops while your transaction waits, you pay the lower one. If the transaction runs out of gas or reverts, the gas used up to that point is still charged.
Working out the cost
Gas prices are quoted in gwei, a billionth of an ETH (1 ETH = 1,000,000,000 gwei). Here is a mainnet swap with illustrative numbers, not current prices:
- Gas used
- 150,000
- typical swap
- Base fee
- 20 gwei
- example
- Priority fee
- 2 gwei
- example
- Total
- 0.0033 ETH
- about $9.90 at $3,000/ETH
150,000 × 22 gwei = 3,300,000 gwei = 0.0033 ETH. At 2 gwei instead of 22, the same swap costs ten times less. Gas units barely change between quiet and busy hours; the price per unit is what moves.
Why layer 2 is cheaper
Rollups such as Arbitrum, Base, Optimism and Linea execute transactions on their own chain and post compressed data back to Ethereum for security. Your fee has two parts: a very small execution fee on the layer 2, and your share of the cost of posting that data to Ethereum.
The Dencun upgrade (March 2024, EIP-4844) gave rollups a cheaper place to post data, called blobs, which cut the data part sharply. Polygon, BNB Chain and Avalanche are separate chains with their own validators, fee markets and gas tokens.
| Network | Gas paid in | Fee model |
|---|---|---|
| Ethereum | ETH | Layer 1, EIP-1559 base fee plus tip |
| Arbitrum | ETH | Layer 2 execution plus Ethereum data fee |
| Base | ETH | Layer 2 execution plus Ethereum data fee |
| Optimism | ETH | Layer 2 execution plus Ethereum data fee |
| Linea | ETH | Layer 2 (zk rollup) execution plus Ethereum data fee |
| Polygon | POL | Independent chain with its own fee market |
| BNB Chain | BNB | Independent chain with its own fee market |
| Avalanche | AVAX | Independent chain with its own fee market |
You need a little of the gas token on each network you use. Read layer 2 networks for how rollups work.
Practical ways to pay less
Swap on a layer 2
The same swap usually costs cents on Arbitrum, Base, Optimism or Linea instead of dollars on mainnet. If your funds are already there, stay there.
Pick a quiet moment on mainnet
Ethereum base fee follows demand. Nights and weekends (UTC) are often quieter. Check a gas tracker before a non-urgent trade.
Avoid failed transactions
A revert still burns the gas used up to the failure. Refresh stale quotes and let simulation catch a bad transaction before you send it.
Leave the gas limit alone
Lowering it does not save money: unused gas is never charged, and a limit that is too low makes the transaction fail and still cost you.
Approve exactly what you swap
Each new approval is its own transaction. ChainBridge approves the exact amount and, when your wallet supports it, sends approval and swap in one confirmation.
Go gasless when it wins
A gasless swap lets 0x pay the gas and recover it from the trade, useful when you hold no native token. It competes with regular routes on net amount.
How ChainBridge accounts for gas
Gas is part of the price comparison. Each quote's gas cost is converted into the token you receive and subtracted before ranking, so you see the route that leaves you the most, not the one with the biggest headline number. See smart order routing.
On Ethereum, Arbitrum, Base, Optimism, Polygon, BNB Chain and Avalanche, a gasless swap may also be offered: you sign an order, 0x pays the gas, and that cost is taken from the trade. It is not available on Linea, for the native gas token as the token you sell, or from smart contract wallets.
To estimate a specific transaction yourself, use the gas cost calculator.