hardhat.config.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /// ENVVAR
  2. // - ENABLE_GAS_REPORT
  3. // - CI
  4. // - COMPILE_MODE
  5. const fs = require('fs');
  6. const path = require('path');
  7. const argv = require('yargs/yargs')()
  8. .env('')
  9. .boolean('enableGasReport')
  10. .boolean('ci')
  11. .string('compileMode')
  12. .argv;
  13. require('@nomiclabs/hardhat-truffle5');
  14. require('solidity-coverage');
  15. if (argv.enableGasReport) {
  16. require('hardhat-gas-reporter');
  17. }
  18. for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) {
  19. require(path.join(__dirname, 'hardhat', f));
  20. }
  21. const withOptimizations = argv.enableGasReport || argv.compileMode === 'production';
  22. /**
  23. * @type import('hardhat/config').HardhatUserConfig
  24. */
  25. module.exports = {
  26. solidity: {
  27. version: '0.8.3',
  28. settings: {
  29. optimizer: {
  30. enabled: withOptimizations,
  31. runs: 200,
  32. },
  33. },
  34. },
  35. networks: {
  36. hardhat: {
  37. blockGasLimit: 10000000,
  38. allowUnlimitedContractSize: !withOptimizations,
  39. },
  40. },
  41. gasReporter: {
  42. currency: 'USD',
  43. outputFile: argv.ci ? 'gas-report.txt' : undefined,
  44. },
  45. };