buidler.config.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. sources: "./contracts",
  68. tests: "./test",
  69. },
  70. solc: {
  71. /* https://buidler.dev/buidler-evm/#solidity-optimizer-support */
  72. optimizer: {
  73. enabled: false,
  74. runs: 200,
  75. },
  76. version: "0.5.12",
  77. },
  78. typechain: {
  79. outDir: "typechain",
  80. target: "ethers-v5",
  81. },
  82. };
  83. export default config;