buidler.config.ts 2.2 KB

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