From 2b480a63f2ca06b6b39d296c65b35267f8f4f1d0 Mon Sep 17 00:00:00 2001 From: Ladd Hoffman Date: Thu, 18 Apr 2024 14:12:50 -0500 Subject: [PATCH] make sepolia and mainnet hardhat networks optional --- README.md | 6 ++++++ ethereum/hardhat.config.js | 20 ++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a62eb1c..70fed24 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,12 @@ or npm install +1. Copy the example configuration file + + cp .env.example .env + +1. In `.env`, set a value for `SEED_PHRASE` or `LOCAL_PRIVATE_KEY` + 1. Run a hardhat node npx hardhat node diff --git a/ethereum/hardhat.config.js b/ethereum/hardhat.config.js index b795b1b..8e0deb5 100644 --- a/ethereum/hardhat.config.js +++ b/ethereum/hardhat.config.js @@ -12,14 +12,18 @@ module.exports = { : [process.env.LOCAL_PRIVATE_KEY], chainId: 1337, }, - sepolia: { - url: `https://sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`, - accounts: [process.env.SEPOLIA_PRIVATE_KEY], - }, - mainnet: { - url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`, - accounts: [process.env.MAINNET_PRIVATE_KEY], - }, + ...process.env.SEPOLIA_PRIVATE_KEY ? { + sepolia: { + url: `https://sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`, + accounts: [process.env.SEPOLIA_PRIVATE_KEY], + }, + } : {}, + ...process.env.MAINNET_PRIVATE_KEY ? { + mainnet: { + url: `https://mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`, + accounts: [process.env.MAINNET_PRIVATE_KEY], + }, + } : {}, }, etherscan: { apiKey: {