Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to provide the RPC URL for a localhost network deployment #13

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ETHERSCAN_API_KEY=<YOUR_ETHERSCAN_KEY>
SEPOLIA_URL=https://eth-sepolia.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
PRIVATE_KEY=<YOUR_PRIVATE_KEY>
RPC_PROVIDER=http://<RPC_IP>:<RPC_PORT>
11 changes: 9 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -34,8 +35,14 @@ const getNetworkConfig = (): NetworksUserConfig | undefined => {
url: "http://localhost:8545",
},
};
} else {
const LOCALHOST_PROVIDER = RPC_PROVIDER || "http://localhost:8545";
return {
localhost_integration: {
url: LOCALHOST_PROVIDER,
},
};
}
return undefined;
};

// You need to export an object to set up your config
Expand Down
Loading