Skip to content

Commit

Permalink
Fix hardhat envs
Browse files Browse the repository at this point in the history
  • Loading branch information
alavarello committed Mar 24, 2024
1 parent 92702f5 commit 6b7e8f7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import '@nomiclabs/hardhat-solhint';
import '@openzeppelin/hardhat-upgrades';
import 'dotenv/config';

function getAccounts(privateKey: string | undefined): string[] {
return privateKey ? [privateKey] : [];
}

function getUrl(url: string | undefined): string {
return url ?? '';
}

const config: HardhatUserConfig = {
solidity: '0.8.20',
gasReporter: {
Expand All @@ -16,8 +24,8 @@ const config: HardhatUserConfig = {
networks: {
goerli: {
chainId: 5,
url: process.env.ETHEREUM_GOERLI_PROVIDER_URL!,
accounts: [process.env.ETHEREUM_GOERLI_PRIVATE_KEY!],
url: getUrl(process.env.ETHEREUM_GOERLI_PROVIDER_URL),
accounts: getAccounts(process.env.ETHEREUM_GOERLI_PRIVATE_KEY),
},
},
etherscan: {
Expand Down

0 comments on commit 6b7e8f7

Please sign in to comment.