此網頁僅供信息參考之用。部分服務和功能可能在您所在的司法轄區不可用。

What is a gas fee?

A gas fee is the amount paid for the network resources consumed by an operation on a blockchain that uses gas accounting. Gas is the accounting unit; the fee is the monetary cost. On Ethereum, gas measures work performed by the Ethereum Virtual Machine (EVM), and execution fees are paid in ETH. Other networks may use different units, fee markets or payment assets, so “gas fee” is not a universal formula for every blockchain.

Gas accounting serves two related purposes. It assigns a cost to computation and data, and it puts a limit on how much work one transaction can ask nodes to perform. This helps allocate limited block space and prevents an execution from running indefinitely. Ethereum’s official gas documentation describes gas as a measure of computational effort rather than a token or a separate balance.

What consumes gas on Ethereum?

An Ethereum transaction has an intrinsic gas cost before contract code runs. That cost reflects the transaction itself, including its data, and contract creation costs more than a basic call. During execution, EVM instructions consume additional gas according to the protocol’s gas schedule. Storage writes, contract calls and other state-dependent operations may therefore use different amounts of gas.

This is why the amount of ETH or tokens transferred does not by itself determine the fee. A small-value interaction with a contract can use more gas than a larger basic ETH transfer. The exact path taken by contract code can also change the final gas used, so an estimate is not a promise of the final result.

Gas limit, gas used and block gas limit

Three similar terms describe different constraints:

  • Transaction gas limit is the maximum gas the sender permits the transaction to consume. It is a safety and execution bound, not the amount automatically charged.
  • Gas used is the chargeable gas recorded after execution and the applicable refund accounting. It is the quantity multiplied by the effective gas price to calculate the execution fee.
  • Block gas limit caps the total gas that transactions in a block can use. It is a network-level constraint, not an individual transaction’s fee setting.

If a transaction’s gas limit is higher than the gas ultimately needed, the unused portion is not charged as if it had been consumed. If the limit is too low for the execution path, however, execution can run out of gas and fail. Ethereum transaction fields and fee fields are summarized in the official transactions documentation.

For an ordinary Ethereum execution transaction, the central relationship is:

Execution fee = chargeable gas used × effective gas price

This equation describes the execution-gas component. It does not necessarily describe every fee associated with a layer-2 transaction, a platform withdrawal or a transaction type with a separate fee market.

How EIP-1559 sets the effective gas price

For an EIP-1559 transaction, the sender specifies two per-gas caps:

  • Max priority fee per gas (maxPriorityFeePerGas) caps the tip offered to the block proposer.
  • Max fee per gas (maxFeePerGas) caps the combined base fee and priority fee the sender is willing to pay per gas.

Every Ethereum execution block has a base fee set by the protocol. It changes in response to how much gas earlier blocks used relative to the protocol’s target, and the base-fee portion paid by a transaction is burned. A transaction’s priority-fee portion is credited to the block proposer. These mechanics are specified in EIP-1559.

The effective priority fee is constrained by both user-defined caps:

Effective priority fee = min(max priority fee, max fee − block base fee)

Effective gas price = block base fee + effective priority fee

The max fee is therefore a ceiling, not a quotation of what will be charged. If the max fee cannot cover the block’s base fee, the transaction is not eligible for inclusion in that block. A larger cap may allow the transaction to remain valid if the base fee rises, but it does not by itself make the full cap payable. It also cannot guarantee when a validator will include the transaction.

Older transaction formats use one gasPrice field instead of the two EIP-1559 caps. In either format, the useful distinction for a reader is between the maximum price authorized and the effective price charged for an included transaction.

Reading a fee calculation

Suppose an EIP-1559 transaction has these hypothetical values:

  • Transaction gas limit: 80,000 gas
  • Chargeable gas used: 50,000 gas
  • Block base fee: 20 gwei per gas
  • Max priority fee: 3 gwei per gas
  • Max fee: 22 gwei per gas

The max fee leaves only 2 gwei above the base fee, so the effective priority fee is min(3, 22 − 20) = 2 gwei. The effective gas price is 22 gwei and the execution fee is:

50,000 × 22 gwei = 1,100,000 gwei = 0.0011 ETH

The calculation uses 50,000 gas, not the 80,000-gas transaction limit. It also illustrates why the displayed max priority fee is not always the priority fee ultimately paid. These values are only an explanation of the arithmetic, not a live fee estimate or a typical price for a particular operation.

Unused gas, refunds and failed transactions

The word refund is used for two different mechanisms:

  1. Unused transaction gas: a gas limit is a maximum. Gas not consumed by execution is not ultimately charged at the effective price. Likewise, the difference between a fee cap and the effective gas price is not an extra fee simply because the sender authorized that cap.
  2. EVM execution refunds: certain state changes can add units to an internal refund counter. This reduces chargeable gas after execution; it does not send a separate payment during contract execution or give the contract more gas to continue running.

The second mechanism is deliberately limited. EIP-3529 removed the refund for SELFDESTRUCT, reduced the refund associated with clearing storage and capped the applied refund at one-fifth of gas spent. This protocol-level accounting is mostly relevant to developers; for a general reader, the key point is that unused gas and an EVM refund are not two cash payments sent back by a contract.

A failed transaction may still have a fee because “failed” can describe several outcomes:

“Failed” can describe several technically different outcomes:

  • Included and reverted: nodes have already performed work. State changes are rolled back, but gas spent before the revert remains chargeable. Under EIP-140, REVERT does not automatically consume all remaining gas.
  • Out of gas: the failing execution context can consume all gas made available to it. A top-level transaction that runs out of gas can consume its full transaction gas limit.
  • Rejected before inclusion: no onchain execution occurred, so there is no Ethereum execution fee for an included transaction. An application error message alone does not prove that a network fee was paid.

For an included failed transaction, the receipt and block data—not only the interface message—show the status and gas used. The fee and sender nonce change are part of processing the included transaction even though the reverted contract-state changes do not persist.

Where the Ethereum formula stops applying

Gas is a broad design pattern, but the terms above describe Ethereum’s execution layer. Other chains may use fixed fees, resource credits, multiple fee assets or different auction rules. Even within the Ethereum ecosystem, a layer-2 fee may combine local execution with the cost of publishing data to Ethereum. EIP-4844 also defines blob gas as independent of normal execution gas, with its own fee accounting.

A centralized platform’s withdrawal fee is another distinct concept: it may reflect a platform’s fee policy and batching practices rather than equal the network fee for one onchain transaction. These amounts should not be used interchangeably without checking what the interface actually labels.

FAQ

Is gas a separate coin?

No. On Ethereum, gas is a resource-accounting unit and the execution fee is denominated in ETH. Another network may use its own native asset or a different payment mechanism.

Does setting a higher gas limit make a transaction more expensive?

Not by itself. The fee is based on chargeable gas used, not automatically on the entire limit. A higher limit does, however, authorize more execution and increases the transaction’s maximum possible gas exposure.

Does a higher max fee guarantee faster confirmation?

No. The max fee is a cap and must be high enough to cover the base fee. Inclusion also depends on the effective priority fee, available block space, validator selection and changing network conditions.

For a longer Ethereum-focused explanation, read Ethereum gas fees explained.

Explore blockchain addresses and crypto wallets, or return to the Crypto Glossary.

Sources

免責聲明
本文章可能包含不適用於您所在地區的產品相關內容。本文僅致力於提供一般性信息,不對其中的任何事實錯誤或遺漏負責任。本文僅代表作者個人觀點,不代表 OKX 的觀點。 本文無意提供以下任何建議,包括但不限於:(i) 投資建議或投資推薦;(ii) 購買、出售或持有數字資產的要約或招攬;或 (iii) 財務、會計、法律或稅務建議。 持有的數字資產 (包括穩定幣) 涉及高風險,可能會大幅波動,甚至變得毫無價值。您應根據自己的財務狀況仔細考慮交易或持有數字資產是否適合您。有關您具體情況的問題,請諮詢您的法律/稅務/投資專業人士。本文中出現的信息 (包括市場數據和統計信息,如果有) 僅供一般參考之用。儘管我們在準備這些數據和圖表時已採取了所有合理的謹慎措施,但對於此處表達的任何事實錯誤或遺漏,我們不承擔任何責任。 © 2026 OKX。本文可以全文複製或分發,也可以使用本文 100 字或更少的摘錄,前提是此類使用是非商業性的。整篇文章的任何複製或分發亦必須突出說明:“本文版權所有 © 2026 OKX,經許可使用。”允許的摘錄必須引用文章名稱並包含出處,例如“文章名稱,[作者姓名 (如適用)],© 2026 OKX”。部分內容可能由人工智能 (AI) 工具生成或輔助生成。不允許對本文進行衍生作品或其他用途。

相關推薦

查看更多
what-is-blockchain

What is a blockchain?

A blockchain is a digital record book maintained by multiple participants. New records are organized into blocks, and the blocks are connected in order. Computers participating in the blockchain netwo
2026年10月29日
crypto-glossary-cover-v5.contentful

Crypto Glossary A–Z

Explore key crypto, blockchain, and trading terms through concise definitions, organized alphabetically for quick reference. [A](#a) · [B](#b) · [C](#c) · [D](#d) · [E](#e) · [F](#f) · [G](#g) · [H](#
2026年10月29日
Crypto adoption generic thumbnail

What is DeFi?

Decentralized finance (DeFi) is a class of application that provides financial functions such as asset swapping and lending mainly through blockchains and smart contracts. A smart contract is a progra
2026年10月29日
decentralized-exchange-dex

What is a DEX?

A decentralized exchange (DEX) is a class of trading system that lets users swap digital assets through blockchain protocols or smart contracts. A smart contract is a program deployed on a blockchain
2026年10月29日
thumbnail:dao

What is a DAO?

A decentralized autonomous organization (DAO) is a way of organizing in which several people make decisions, manage funds or maintain a project together under rules agreed in advance. It often records
2026年10月29日
DApps generic thumb

What is a DApp?

A decentralized application (DApp) is an application that hands some of its core rules or state — balances, ownership and approval records, for example — to a decentralized network such as a blockchai
2026年10月29日
查看更多