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