标签:文件大小 sizer true require 编译 accounts Hardhat hardhat config
Hardhat Contract Sizer
安装(windows环境):
yarn add --dev hardhat-contract-sizer
添加下列代码至hardhat.config.js配置文件
require('hardhat-contract-sizer');
contractSizer: {
alphaSort: true,
runOnCompile: true,
disambiguatePaths: false,
}
执行:
1.
yarn run hardhat size-contracts
or
2.添加运行脚本至package.json
"scripts": {
"accounts": "hardhat accounts",
"clean": "hardhat clean",
"compile": "hardhat compile",
"sizer": "hardhat size-contracts"
},
hardhat.config.js:
require("@nomiclabs/hardhat-etherscan");
require("@nomiclabs/hardhat-waffle");
// get contract sizer
require('hardhat-contract-sizer');
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: {
version: '0.8.4',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
contractSizer: {
alphaSort: true,
runOnCompile: true,
disambiguatePaths: false,
},
networks: {
tbsc: {
url: "https://data-seed-prebsc-1-s1.binance.org:8545/",
accounts:
["private key"],
},
},
};
标签:文件大小,sizer,true,require,编译,accounts,Hardhat,hardhat,config 来源: https://blog.csdn.net/weixin_43405220/article/details/122319876
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。