Skip to content

Commit

Permalink
feat: add arbitrum,avalanche,bsc and optimism
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulRBerg committed Feb 21, 2022
1 parent c0a9e2e commit 2186ed4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ ETHERSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
OPTIMISM_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
POLYGONSCAN_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"
SNOWTRACE_API_KEY="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"

30 changes: 20 additions & 10 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ import { NetworkUserConfig } from "hardhat/types";

dotenvConfig({ path: resolve(__dirname, "./.env") });

const chainIds = {
goerli: 5,
hardhat: 31337,
kovan: 42,
mainnet: 1,
rinkeby: 4,
ropsten: 3,
};

// Ensure that we have all the environment variables we need.
const mnemonic: string | undefined = process.env.MNEMONIC;
if (!mnemonic) {
Expand All @@ -35,6 +26,20 @@ if (!infuraApiKey) {
throw new Error("Please set your INFURA_API_KEY in a .env file");
}

const chainIds = {
arbitrumOne: 42161,
avalanche: 43114,
bsc: 56,
goerli: 5,
hardhat: 31337,
kovan: 42,
mainnet: 1,
optimism: 10,
polygon: 137,
rinkeby: 4,
ropsten: 3,
};

function getChainConfig(network: keyof typeof chainIds): NetworkUserConfig {
const url: string = "https://" + network + ".infura.io/v3/" + infuraApiKey;
return {
Expand All @@ -53,7 +58,6 @@ const config: HardhatUserConfig = {
etherscan: {
apiKey: {
arbitrumOne: process.env.ARBSCAN_API_KEY,
arbitrumTestnet: process.env.ARBSCAN_API_KEY,
avalanche: process.env.SNOWTRACE_API_KEY,
bsc: process.env.BSCSCAN_API_KEY,
goerli: process.env.ETHERSCAN_API_KEY,
Expand All @@ -78,8 +82,14 @@ const config: HardhatUserConfig = {
},
chainId: chainIds.hardhat,
},
arbitrumOne: getChainConfig("arbitrumOne"),
avalanche: getChainConfig("avalanche"),
bsc: getChainConfig("bsc"),
goerli: getChainConfig("goerli"),
kovan: getChainConfig("kovan"),
mainnet: getChainConfig("mainnet"),
optimism: getChainConfig("optimism"),
polygon: getChainConfig("polygon"),
rinkeby: getChainConfig("rinkeby"),
ropsten: getChainConfig("ropsten"),
},
Expand Down

0 comments on commit 2186ed4

Please sign in to comment.