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

private_key to wallet_private_key #168

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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`.

Expand All @@ -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.

Expand Down
10 changes: 5 additions & 5 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,28 +66,28 @@ 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,
// },
chainId: 11155111,
},
mainnet: {
url: MAINNET_RPC_URL,
accounts: PRIVATE_KEY !== undefined ? [PRIVATE_KEY] : [],
accounts: WALLET_PRIVATE_KEY !== undefined ? [WALLET_PRIVATE_KEY] : [],
// accounts: {
// mnemonic: MNEMONIC,
// },
chainId: 1,
},
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,
},
},
Expand Down