Reputation: 643
I'm attempting to follow the NFT tutorial here. I have set up the accounts on Alchemy and Metamask created the .sol file. I have a .env file in root that looks like this:
API_URL = "https://eth-ropsten.alchemyapi.io/v2/your-api-key"
PRIVATE_KEY = "your-metamask-private-key"
My hardhat config file looks like this:
/**
* @type import('hardhat/config').HardhatUserConfig
*/
require('dotenv').config();
require("@nomiclabs/hardhat-ethers");
const { API_URL, PRIVATE_KEY } = process.env;
module.exports = {
solidity: {
compilers: [
{
version: "0.5.7"
},
{
version: "0.8.0"
},
{
version: "0.6.12"
}
]
},
defaultNetwork: "ropsten",
networks: {
hardhat: {},
ropsten: {
url: API_KEY,
accounts: [`0x${PRIVATE_KEY}`]
}
},
}
However when I try to compile I keep getting this error:
Invalid value {"url":"https://eth-ropsten.alchemyapi.io/v2/your-api-key","accounts":["0xyour-metamask-private-key"]} for HardhatConfig.networks.ropsten - Expected a value of type HttpNetworkConfig.
I cannot seem to figure out why this is not a valid value for HttpNetworkConfig. What I have where url is a string and accounts is an array would appear to comply with what is in the documentation for network configs. It's a compile error so it would seem it cannot be a problem with the actual url or private key, but maybe I'm wrong about that. I willingly admit to being a noob here with only a cursory understanding of hardhat, solidity, and even js, etc. Any help appreciated.
Upvotes: 6
Views: 6310
Reputation: 165
Turns out I was missing a value for my LIVE_PRIVATE_KEY
as I also had a DEV_PRIVATE_KEY
Upvotes: 0
Reputation: 31
You are probably working at localhost:8545
.
I think the issue is the value of the assets and some accounts used in your context exist on the mainnet
.
To solve this problem, you need to hardfork
the mainnet
to your local.
Please check this guide. https://hardhat.org/hardhat-network/guides/mainnet-forking.html
Upvotes: 0
Reputation: 643
Turns out, the problem was with my private key. Check carefully.
Upvotes: 3