hardhat.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. .options({
  10. ci: {
  11. type: 'boolean',
  12. default: false,
  13. },
  14. gas: {
  15. alias: 'enableGasReport',
  16. type: 'boolean',
  17. default: false,
  18. },
  19. mode: {
  20. alias: 'compileMode',
  21. type: 'string',
  22. choices: [ 'production', 'development' ],
  23. default: 'development',
  24. },
  25. compiler: {
  26. alias: 'compileVersion',
  27. type: 'string',
  28. default: '0.8.3',
  29. },
  30. })
  31. .argv;
  32. require('@nomiclabs/hardhat-truffle5');
  33. require('solidity-coverage');
  34. if (argv.enableGasReport) {
  35. require('hardhat-gas-reporter');
  36. }
  37. for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) {
  38. require(path.join(__dirname, 'hardhat', f));
  39. }
  40. const withOptimizations = argv.enableGasReport || argv.compileMode === 'production';
  41. /**
  42. * @type import('hardhat/config').HardhatUserConfig
  43. */
  44. module.exports = {
  45. solidity: {
  46. version: argv.compiler,
  47. settings: {
  48. optimizer: {
  49. enabled: withOptimizations,
  50. runs: 200,
  51. },
  52. },
  53. },
  54. networks: {
  55. hardhat: {
  56. blockGasLimit: 10000000,
  57. allowUnlimitedContractSize: !withOptimizations,
  58. },
  59. },
  60. gasReporter: {
  61. currency: 'USD',
  62. outputFile: argv.ci ? 'gas-report.txt' : undefined,
  63. },
  64. };