-
The following error seems pretty self explanatory, but I don't understand why the .env imports aren't being recognized as strings? I THINK things are written as @PatrickAlphaC has them >.>
Here's the config require("@nomiclabs/hardhat-waffle");
require("dotenv").config();
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
const RINKEBY_RPC_URL = process.env.RINKEBY_RPC_URL;
const PRIVATE_KEY = process.env.PRIVATE_KEY;
module.exports = {
defaultNetwork: "hardhat",
networks: {
rinkeby: {
url: RINKEBY_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 4,
},
},
solidity: "0.8.8",
}; |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 24 replies
-
Did you create a .env file and put RINKEBY_RPC_URL and PRIVATE_KEY inside it? |
Beta Was this translation helpful? Give feedback.
-
I dunno how to bump this request.. but I'm still struggling. lol |
Beta Was this translation helpful? Give feedback.
-
I had the same error. Change |
Beta Was this translation helpful? Give feedback.
I had the same error.
The first thing I did was to
console.log(process.env.RINKEBY_RPC_URL)
to see if we were reading it correctly. It returnedundefined
so it was not reading it correctly, but the other .env variables were read correctly.Change
RINKEBY_RPC_URL
toRINKEBY_URL
everywhere (code and .env) and it should work.