# EIP-1559 手續費計算規則 手續費由價格和數量兩者相乘,價格是 gas price (單位通常用 gwei),數量是 gas used (單位通常用 gas)。gas price 取決於礦工與區塊鏈的交通狀況,gas used 取決於該筆交易運算的複雜度。 ``` Transaction Fee = gasPrice * gasUsed ``` maxFeePerGas & maxPriorityFeePerGas 都是 gas price,讓用戶能限制一筆交易的價格上限。 一筆交易送上鏈,區塊鏈先吃第一口(<=maxFeePerGas),吃剩的給礦工吃(<=maxPriorityFeePerGas),最後剩下的還給用戶。 每個區塊吃的價格為 baseFeePerGas,可以在歷史的區塊欄位中查到。 maxFeePerGas < baseFeePerGas,交易會被卡在 mempool 上不了鏈,等到 baseFeePerGas 價格下跌低於 maxFeePerGas 才可能上鏈。 若 maxPriorityFeePerGas 設太低,礦工可能不打包用戶的交易,礦工能吃多少取決於: ``` min(maxPriorityFeePerGas, maxFeePerGas - baseFeePerGas) ``` 若用戶將 maxFeePerGas 設成 baseFeePerGas,礦工一定吃不到,因此可能不被礦工打包上鏈。 交易結束後,用戶真正花費的價格稱作 effectiveGasPrice: ``` effectiveGasPrice = min(maxFeePerGas, baseFeePerGas + maxPriorityFeePerGas) ``` 詳見[倫敦升級之後的 gas 費用計算](https://medium.com/taipei-ethereum-meetup/eip-1559-tx-fee-232576cc11dc)
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.