buidler.config.ts 1.9 KB

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