From 8790db0669843a72568e0bf533a5b522ca88a75a Mon Sep 17 00:00:00 2001 From: stubbsta Date: Wed, 20 Mar 2024 12:57:58 +0200 Subject: [PATCH 1/2] add option to provide the RPC URL for a localhost network deployment --- .env.example | 1 + hardhat.config.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index a041c5d..dc12235 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ ETHERSCAN_API_KEY= SEPOLIA_URL=https://eth-sepolia.alchemyapi.io/v2/ PRIVATE_KEY= +RPC_PROVIDER=http://: diff --git a/hardhat.config.ts b/hardhat.config.ts index ed6662b..98d68cf 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -12,7 +12,8 @@ import "hardhat-gas-reporter"; import "solidity-docgen"; dotenv.config(); -const { SEPOLIA_URL, PRIVATE_KEY, ETHERSCAN_API_KEY } = process.env; +const { SEPOLIA_URL, PRIVATE_KEY, ETHERSCAN_API_KEY, RPC_PROVIDER } = + process.env; const getNetworkConfig = (): NetworksUserConfig | undefined => { if (SEPOLIA_URL && PRIVATE_KEY) { @@ -34,6 +35,12 @@ const getNetworkConfig = (): NetworksUserConfig | undefined => { url: "http://localhost:8545", }, }; + } else if (RPC_PROVIDER) { + return { + localhost_integration: { + url: RPC_PROVIDER, + }, + }; } return undefined; }; From 23549614cafee588c127f15f3ea09adf0e0f0187 Mon Sep 17 00:00:00 2001 From: stubbsta Date: Wed, 20 Mar 2024 15:12:40 +0200 Subject: [PATCH 2/2] deploy localhost uses provided RPC URL or default --- hardhat.config.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hardhat.config.ts b/hardhat.config.ts index 98d68cf..2e1d9e8 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -35,14 +35,14 @@ const getNetworkConfig = (): NetworksUserConfig | undefined => { url: "http://localhost:8545", }, }; - } else if (RPC_PROVIDER) { + } else { + const LOCALHOST_PROVIDER = RPC_PROVIDER || "http://localhost:8545"; return { localhost_integration: { - url: RPC_PROVIDER, + url: LOCALHOST_PROVIDER, }, }; } - return undefined; }; // You need to export an object to set up your config