From 84b3866a9e9e82b27d4b314c769b55821e34df12 Mon Sep 17 00:00:00 2001 From: Naman Date: Sat, 6 May 2023 13:13:45 +0530 Subject: [PATCH 1/2] private_key to wallet_private_key --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 63d48d50..88e825a1 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ POLYGON_MAINNET_RPC_URL='https://rpc-mainnet.maticvigil.com' MUMBAI_RPC_URL='https://polygon-mumbai.g.alchemy.com/v2/1234567890' SEPOLIA_RPC_URL='https://sepolia.infura.io/v3/1234567890' -PRIVATE_KEY='abcdefg' +WALLET_PRIVATE_KEY='abcdefg' ALCHEMY_MAINNET_RPC_URL="https://eth-mainnet.alchemyapi.io/v2/your-api-key" REPORT_GAS=true COINMARKETCAP_API_KEY="YOUR_KEY" From be8f65010e4ef8e00cab09d013f1894ef137552b Mon Sep 17 00:00:00 2001 From: Naman Date: Fri, 12 May 2023 23:43:37 +0530 Subject: [PATCH 2/2] changes in hardhat.config.js and README.md --- README.md | 10 +++++----- hardhat.config.js | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c00e43fd..fcd6639b 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ This section of the file is where you define which networks you want to interact To interact with a live or test network, you'll need: 1. An rpc URL -2. A Private Key +2. A wallet private Key 3. ETH & LINK token (either testnet or real) Let's look at an example of setting these up using the Sepolia testnet. @@ -168,7 +168,7 @@ First, we will need to set environment variables. We can do so by setting them i You can get one for free from [Alchemy](https://www.alchemy.com/), [Infura](https://infura.io/), or [Moralis](https://moralis.io/speedy-nodes/). This is your connection to the blockchain. -2. Set your `PRIVATE_KEY` environment variable. +2. Set your `WALLET_PRIVATE_KEY` environment variable. This is your private key from your wallet, ie [MetaMask](https://metamask.io/). This is needed for deploying contracts to public networks. You can optionally set your `MNEMONIC` environment variable instead with some changes to the `hardhat.config.js`. @@ -181,15 +181,15 @@ Don't commit and push any changes to .env files that may contain sensitive infor `.env` example: ``` SEPOLIA_RPC_URL='https://sepolia.infura.io/v3/asdfadsfafdadf' -PRIVATE_KEY='abcdef' +WALLET_PRIVATE_KEY='abcdef' ``` `bash` example: ``` export SEPOLIA_RPC_URL='https://sepolia.infura.io/v3/asdfadsfafdadf' -export PRIVATE_KEY='abcdef' +export WALLET_PRIVATE_KEY='abcdef' ``` -> You can also use a `MNEMONIC` instead of a `PRIVATE_KEY` environment variable by uncommenting the section in the `hardhat.config.js`, and commenting out the `PRIVATE_KEY` line. However this is not recommended. +> You can also use a `MNEMONIC` instead of a `WALLET_PRIVATE_KEY` environment variable by uncommenting the section in the `hardhat.config.js`, and commenting out the `WALLET_PRIVATE_KEY` line. However this is not recommended. For other networks like mainnet and polygon, you can use different environment variables for your RPC URL and your private key. See the `hardhat.config.js` to learn more. diff --git a/hardhat.config.js b/hardhat.config.js index fe4d1172..51846a88 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -22,7 +22,7 @@ const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL; const MUMBAI_RPC_URL = process.env.MUMBAI_RPC_URL || "https://polygon-mumbai.g.alchemy.com/v2/your-api-key" -const PRIVATE_KEY = process.env.PRIVATE_KEY +const WALLET_PRIVATE_KEY = process.env.WALLET_PRIVATE_KEY // optional const MNEMONIC = process.env.MNEMONIC || "Your mnemonic" const FORKING_BLOCK_NUMBER = parseInt(process.env.FORKING_BLOCK_NUMBER) || 0 @@ -66,7 +66,7 @@ module.exports = { }, sepolia: { url: SEPOLIA_RPC_URL !== undefined ? SEPOLIA_RPC_URL : "", - accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [], + accounts: WALLET_PRIVATE_KEY !== undefined ? [WALLET_PRIVATE_KEY] : [], // accounts: { // mnemonic: MNEMONIC, // }, @@ -74,7 +74,7 @@ module.exports = { }, mainnet: { url: MAINNET_RPC_URL, - accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [], + accounts: WALLET_PRIVATE_KEY !== undefined ? [WALLET_PRIVATE_KEY] : [], // accounts: { // mnemonic: MNEMONIC, // }, @@ -82,12 +82,12 @@ module.exports = { }, polygon: { url: POLYGON_MAINNET_RPC_URL, - accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [], + accounts: WALLET_PRIVATE_KEY !== undefined ? [WALLET_PRIVATE_KEY] : [], chainId: 137, }, mumbai: { url: MUMBAI_RPC_URL, - accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [], + accounts: WALLET_PRIVATE_KEY !== undefined ? [WALLET_PRIVATE_KEY] : [], chainId: 80001, }, },