Skip to content

Commit

Permalink
Merge pull request #151 from gnosisguild/sam/private-key-deployment
Browse files Browse the repository at this point in the history
Allow deploying contracts from a specific private key
  • Loading branch information
samepant authored Oct 18, 2024
2 parents 95d32d8 + bf22b1e commit c30f1b4
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 107 deletions.
6 changes: 4 additions & 2 deletions packages/evm/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
MNEMONIC=
INFURA_KEY=
ETHERSCAN_API_KEY=

ETHERSCAN_API_KEY=
# only one of the following should be set
PRIVATE_KEY=
MNEMONIC=
66 changes: 33 additions & 33 deletions packages/evm/deployments/sepolia/CiphernodeRegistryOwnable.json

Large diffs are not rendered by default.

74 changes: 37 additions & 37 deletions packages/evm/deployments/sepolia/Enclave.json

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions packages/evm/deployments/sepolia/NaiveRegistryFilter.json

Large diffs are not rendered by default.

28 changes: 19 additions & 9 deletions packages/evm/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ import "./tasks/enclave";

dotenv.config();

const { INFURA_KEY, MNEMONIC, ETHERSCAN_API_KEY } = process.env;
const { INFURA_KEY, MNEMONIC, PRIVATE_KEY, ETHERSCAN_API_KEY } = process.env;

if (!INFURA_KEY || !MNEMONIC || !ETHERSCAN_API_KEY) {
console.error(
"Please set the INFURA_KEY, MNEMONIC, and ETHERSCAN_API_KEY environment variables",
if (!INFURA_KEY || !ETHERSCAN_API_KEY) {
console.warn(
"Please set the INFURA_KEY, and ETHERSCAN_API_KEY environment variables to deploy and verify contracts",
);
}

if (!MNEMONIC && !PRIVATE_KEY) {
console.warn(
"Please set a mnemonic or private key to deploy contracts. If you set neither, hardhat will use a default mnemonic",
);
}

Expand Down Expand Up @@ -49,12 +55,16 @@ function getChainConfig(chain: keyof typeof chainIds): NetworkUserConfig {
default:
jsonRpcUrl = "https://" + chain + ".infura.io/v3/" + infuraApiKey;
}

let accounts;
if (PRIVATE_KEY) {
accounts = [PRIVATE_KEY];
} else {
accounts = { mnemonic };
}

return {
accounts: {
count: 10,
mnemonic,
path: "m/44'/60'/0'/0",
},
accounts,
chainId: chainIds[chain],
url: jsonRpcUrl,
};
Expand Down

0 comments on commit c30f1b4

Please sign in to comment.