【Hardhat 获取函数Gas费用报表】

  • 使用插件hardhat-gas-reporter参考
  • 安装yarn add hardhat-gas-reporter --dev
  • hardhat.config.js配置
require("hardhat-gas-reporter")

module.exports = {
  ...
  gasReporter: {
    enabled: true
  }
};
  • 执行yarn hardhat test,默认会执行获取gas报表的数据
> yarn hardhat test
yarn run v1.22.19
..\node_modules\.bin\hardhat test

  SimpleStorage
    ✔ Should start with a favorite number of 0
    ✔ Should update when we call store

·----------------------------|----------------------------|-------------|-----------------------------·
|    Solc version: 0.8.19    ·  Optimizer enabled: false  ·  Runs: 200  ·  Block limit: 30000000 gas  │
·····························|····························|·············|······························
|  Methods                                                                                            │
··················|··········|··············|·············|·············|···············|··············
|  Contract       ·  Method  ·  Min         ·  Max        ·  Avg        ·  # calls      ·  usd (avg)  │
··················|··········|··············|·············|·············|···············|··············
|  SimpleStorage  ·  store   ·           -  ·          -  ·      43724  ·            2  ·          -  │
··················|··········|··············|·············|·············|···············|··············
|  Deployments               ·                                          ·  % of limit   ·             │
·····························|··············|·············|·············|···············|··············
|  SimpleStorage             ·           -  ·          -  ·     562691  ·        1.9 %  ·          -  │
·----------------------------|--------------|-------------|-------------|---------------|-------------·

  2 passing (1s)

Done in 2.85s.
  • 插件solidity-coverage使用,检测还有哪些行没有参与测试的,参考
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值