buidler.config.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 createBuidlerConfig(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. ...createBuidlerConfig(),
  46. url: "http://127.0.0.1:8555",
  47. },
  48. goerli: {
  49. ...createBuidlerConfig("goerli"),
  50. chainId: 5,
  51. },
  52. kovan: {
  53. ...createBuidlerConfig("kovan"),
  54. chainId: 42,
  55. },
  56. rinkeby: {
  57. ...createBuidlerConfig("rinkeby"),
  58. chainId: 4,
  59. },
  60. ropsten: {
  61. ...createBuidlerConfig("ropsten"),
  62. chainId: 3,
  63. },
  64. },
  65. paths: {
  66. artifacts: "./artifacts",
  67. cache: "./cache",
  68. coverage: "./coverage",
  69. coverageJson: "./coverage.json",
  70. root: "./",
  71. sources: "./contracts",
  72. tests: "./test",
  73. },
  74. solc: {
  75. /* https://buidler.dev/buidler-evm/#solidity-optimizer-support */
  76. optimizer: {
  77. enabled: false,
  78. runs: 200,
  79. },
  80. version: "0.7.2",
  81. },
  82. typechain: {
  83. outDir: "typechain",
  84. target: "ethers-v5",
  85. },
  86. };
  87. export default config;