updated config: etherscan <0.3.0>

This commit is contained in:
pradyuman-verma 2022-03-19 13:19:50 +05:30
parent bfd21e250e
commit 3177d6a8aa
No known key found for this signature in database
GPG Key ID: E36FD6BC8923221F

View File

@ -42,18 +42,20 @@ const FANTOMSCAN_API = process.env.FANTOM_API_KEY;
const OPTIMISM_API = process.env.OPTIMISM_API_KEY; const OPTIMISM_API = process.env.OPTIMISM_API_KEY;
const mnemonic = process.env.MNEMONIC ?? "test test test test test test test test test test test junk"; const mnemonic = process.env.MNEMONIC ?? "test test test test test test test test test test test junk";
const networkGasPriceConfig: Record<string, string> = { const networkGasPriceConfig: Record<string, number> = {
mainnet: "160", mainnet: 100,
polygon: "50", polygon: 50,
avalanche: "50", avalanche: 30,
arbitrum: "2" arbitrum: 1,
optimism: 0.001,
fantom: 300
}; };
function createConfig(network: string) { function createConfig(network: string) {
return { return {
url: getNetworkUrl(network), url: getNetworkUrl(network),
accounts: !!PRIVATE_KEY ? [`0x${PRIVATE_KEY}`] : { mnemonic } accounts: !!PRIVATE_KEY ? [`0x${PRIVATE_KEY}`] : { mnemonic },
// gasPrice: 1000000, // 0.0001 GWEI gasPrice: networkGasPriceConfig[network] * 1e9 // Update the mapping above
}; };
} }
@ -66,16 +68,6 @@ function getNetworkUrl(networkType: string) {
else return `https://eth-mainnet.alchemyapi.io/v2/${alchemyApiKey}`; else return `https://eth-mainnet.alchemyapi.io/v2/${alchemyApiKey}`;
} }
function getScanApiKey(networkType: string) {
if (networkType === "avalanche") return SNOWTRACE_API;
else if (networkType === "polygon") return POLYGONSCAN_API;
else if (networkType === "arbitrum") return ARBISCAN_API;
else if (networkType === "fantom") return FANTOMSCAN_API;
else if (networkType === "fantom") return FANTOMSCAN_API;
else if (networkType === "optimism") return OPTIMISM_API;
else return ETHERSCAN_API;
}
/** /**
* @type import('hardhat/config').HardhatUserConfig * @type import('hardhat/config').HardhatUserConfig
*/ */
@ -126,7 +118,14 @@ const config: HardhatUserConfig = {
tests: "./test" tests: "./test"
}, },
etherscan: { etherscan: {
apiKey: getScanApiKey(String(process.env.networkType)) apiKey: {
mainnet: String(process.env.MAIN_ETHSCAN_KEY),
optimisticEthereum: String(process.env.OPT_ETHSCAN_KEY),
polygon: String(process.env.POLY_ETHSCAN_KEY),
arbitrumOne: String(process.env.ARB_ETHSCAN_KEY),
avalanche: String(process.env.AVAX_ETHSCAN_KEY),
opera: String(process.env.FTM_ETHSCAN_KEY)
}
}, },
typechain: { typechain: {
outDir: "typechain", outDir: "typechain",