xxxxxxxxxx
// shows how much gas is expelled in contract when running tests
// install on hardhat
yarn add hardhat-gas-reporter --dev
// it is starts when you run tests
yarn hardhat test
// hardhat config.js
require("hardhat-gas-reporter");
// call Api key hidden in .env
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_KEY;
gasReporter: {
enabled: true, // false when not in use
outputFile: "gas-report.txt", // export to external file
noColors:true,
currency: "USD"
coinmarketcap: COINMARKETCAP_API_KEY, //live prices from coinmarketcap
token: "MATIC", //you can deploy to different networks , costs for deploying to polygon
},
// add gas-report.txt to .gitignore