Gas

了解 eth-gas-reporter 的輸出

  • March 25, 2022

因此,我正在使用eth-gas-reporter包來了解 gas 功能的成本(通過安全帽測試)。但我不明白輸出。, 是什麼意思5 gwei/gas,calls數字是什麼意思? 下面是我得到的輸出:

·--------------------------|---------------------------|--------------|-----------------------------·
|   Solc version: 0.8.4    ·  Optimizer enabled: true  ·  Runs: 1000  ·  Block limit: 12450000 gas  │
···························|···························|··············|······························
|  Methods                 ·                5 gwei/gas                ·       2875.76 eur/eth       │
·············|·············|·············|·············|··············|···············|··············
|  Contract  ·  Method     ·  Min        ·  Max        ·  Avg         ·  # calls      ·  eur (avg)  │
·············|·············|·············|·············|··············|···············|··············
|  LazyNFT   ·  grantRole  ·          -  ·          -  ·       51386  ·           13  ·       0.74  │
·············|·············|·············|·············|··············|···············|··············
|  LazyNFT   ·  redeem     ·     212579  ·     272375  ·      251672  ·           26  ·       3.62  │
·············|·············|·············|·············|··············|···············|··············
|  LazyNFT   ·  withdraw   ·          -  ·          -  ·       18241  ·            6  ·       0.26  │
·············|·············|·············|·············|··············|···············|··············
|  Deployments             ·                                          ·  % of limit   ·             │
···························|·············|·············|··············|···············|··············
|  LazyNFT                 ·          -  ·          -  ·     2517874  ·       20.2 %  ·      36.20  │
·--------------------------|-------------|-------------|--------------|---------------|-------------·

它向您展示了契約的不同方法及其氣體消耗。

對於您測試的每個函式,它會顯示該函式花費的最小氣體、最大值和平均值。

1 wei = 0.000000001 乙太幣

在你的結果中,它顯示你為2875.76 eur/eth支付****5 gwei/gas,這是推薦的 gwei 數量,你可以查看這個網站以獲得目前的 gas 價格EthGasStation

計算

0.000000001 eth (1gwei) * 5 = 5gwei (測試時的建議)


所以0.000000005 = 5gwei

251672 gas(用於兌換功能的平均 gas 費用)


0.000000005 * 251672 = 0.00125836 ETH

0.00125836*2875.76 (eth price in eur) = 3.6187413536 eur ~= 3.62 eur

引用自:https://ethereum.stackexchange.com/questions/124659