hardhat.config.ts 2.01 KB
Newer Older
1
import { HardhatUserConfig } from 'hardhat/types'
2
import 'solidity-coverage'
3
import * as dotenv from 'dotenv'
4 5 6 7 8 9 10 11 12

import {
  DEFAULT_ACCOUNTS_HARDHAT,
  RUN_OVM_TEST_GAS,
} from './test/helpers/constants'

// Hardhat plugins
import '@nomiclabs/hardhat-ethers'
import '@nomiclabs/hardhat-waffle'
13
import 'hardhat-deploy'
14 15
import '@typechain/hardhat'
import '@eth-optimism/hardhat-ovm'
16
import './tasks/deploy'
17
import 'hardhat-gas-reporter'
18 19 20

// Load environment variables from .env
dotenv.config()
21

22 23
const enableGasReport = !!process.env.ENABLE_GAS_REPORT

24 25 26 27 28
const config: HardhatUserConfig = {
  networks: {
    hardhat: {
      accounts: DEFAULT_ACCOUNTS_HARDHAT,
      blockGasLimit: RUN_OVM_TEST_GAS * 2,
29 30 31
      live: false,
      saveDeployments: false,
      tags: ['local'],
32
      hardfork: 'istanbul',
33
    },
34 35 36 37
    // Add this network to your config!
    optimism: {
      url: 'http://127.0.0.1:8545',
      ovm: true,
38
      saveDeployments: false,
39
    },
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
  },
  mocha: {
    timeout: 50000,
  },
  solidity: {
    version: '0.7.6',
    settings: {
      optimizer: { enabled: true, runs: 200 },
      outputSelection: {
        '*': {
          '*': ['storageLayout'],
        },
      },
    },
  },
55 56 57
  ovm: {
    solcVersion: '0.7.6-allow_kall_2', // temporary until we fix the build for 0.7.6
  },
58 59 60 61
  typechain: {
    outDir: 'dist/types',
    target: 'ethers-v5',
  },
62 63 64 65 66 67 68 69 70
  paths: {
    deploy: './deploy',
    deployments: './deployments',
  },
  namedAccounts: {
    deployer: {
      default: 0,
    },
  },
71 72 73 74 75 76
  gasReporter: {
    enabled: enableGasReport,
    currency: 'USD',
    gasPrice: 100,
    outputFile: process.env.CI ? 'gas-report.txt' : undefined,
  },
77 78 79 80 81 82 83 84 85 86 87 88 89 90
}

if (
  process.env.CONTRACTS_TARGET_NETWORK &&
  process.env.CONTRACTS_DEPLOYER_KEY &&
  process.env.CONTRACTS_RPC_URL
) {
  config.networks[process.env.CONTRACTS_TARGET_NETWORK] = {
    accounts: [process.env.CONTRACTS_DEPLOYER_KEY],
    url: process.env.CONTRACTS_RPC_URL,
    live: true,
    saveDeployments: true,
    tags: [process.env.CONTRACTS_TARGET_NETWORK],
  }
91 92 93
}

export default config