buidler.config.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { config as dotenvConfig } from "dotenv";
  2. import { resolve } from "path";
  3. dotenvConfig({ path: resolve(__dirname, "./.env") });
  4. import { BuidlerConfig, usePlugin } from "@nomiclabs/buidler/config";
  5. import { HDAccountsConfig } from "@nomiclabs/buidler/types";
  6. import "./tasks/accounts";
  7. import "./tasks/clean";
  8. import "./tasks/typechain";
  9. usePlugin("@nomiclabs/buidler-waffle");
  10. usePlugin("solidity-coverage");
  11. interface HDAccountsConfigExtended extends HDAccountsConfig {
  12. url: string;
  13. }
  14. /**
  15. * @dev You must have a `.env` file. Follow the example in `.env.example`.
  16. * @param {string} network The name of the testnet
  17. */
  18. function createHDAccountConfig(network: string): HDAccountsConfigExtended {
  19. if (!process.env.MNEMONIC) {
  20. console.log("Please set your MNEMONIC in a .env file");
  21. process.exit(1);
  22. }
  23. if (!process.env.INFURA_API_KEY) {
  24. console.log("Please set your INFURA_API_KEY");
  25. process.exit(1);
  26. }
  27. return {
  28. initialIndex: 0,
  29. mnemonic: process.env.MNEMONIC,
  30. path: "m/44'/60'/0'/0",
  31. url: `https://${network}.infura.io/v3/${process.env.INFURA_API_KEY}`,
  32. };
  33. }
  34. const config: BuidlerConfig = {
  35. defaultNetwork: "buidlerevm",
  36. mocha: {
  37. delay: true,
  38. },
  39. networks: {
  40. buidlerevm: {
  41. chainId: 31337,
  42. },
  43. coverage: {
  44. url: "http://127.0.0.1:8555",
  45. },
  46. goerli: {
  47. ...createHDAccountConfig("goerli"),
  48. chainId: 5,
  49. },
  50. kovan: {
  51. ...createHDAccountConfig("kovan"),
  52. chainId: 42,
  53. },
  54. rinkeby: {
  55. ...createHDAccountConfig("rinkeby"),
  56. chainId: 4,
  57. },
  58. ropsten: {
  59. ...createHDAccountConfig("ropsten"),
  60. chainId: 3,
  61. },
  62. },
  63. paths: {
  64. artifacts: "./artifacts",
  65. cache: "./cache",
  66. coverage: "./coverage",
  67. coverageJson: "./coverage.json",
  68. root: "./",
  69. sources: "./contracts",
  70. tests: "./test",
  71. },
  72. solc: {
  73. /* https://buidler.dev/buidler-evm/#solidity-optimizer-support */
  74. optimizer: {
  75. enabled: false,
  76. runs: 200,
  77. },
  78. version: "0.6.10",
  79. },
  80. typechain: {
  81. outDir: "typechain",
  82. target: "ethers-v5",
  83. },
  84. };
  85. export default config;