That configuration fairly look complex. Instead of 'fs' you can simply use .env file.
First install, dotenv
Next create .env file.
Inside the file, the values should be like this.
ALCHEMY_API_KEY = "*******"
GOERLI_PRIVATE_KEY = "******"
Next set the configuration file like this:
require("@nomiclabs/hardhat-waffle");
require("dotenv").config();
const { GOERLI_PRIVATE_KEY, ALCHEMY_API_KEY } = process.env;
module.exports = {
solidity: "0.8.9",
networks: {
goerli: {
url: `https://eth-goerli.alchemyapi.io/v2/${ALCHEMY_API_KEY}`,
accounts: [GOERLI_PRIVATE_KEY],
},
},
};
Also your network url is wrong. There shouldn't be .g in the url. You can copy paste mine for the future references.
Tell me if it helps!
EDIT:
So I happened to encounter the same problem as you when I configured new network. Here I was thinking what was the problem, I have configured everything right right?.
Apparently, the problem is not within the url. My URL works correct. And the problem lies in .env file.
Usually the hardhat folder structure is like this:
VSCODE
└── APP
├── contracts
│ ├── contract1.sol
│ └── contract2.sol
├── Scripts
│ ├── 1_contract1.js
│ └── 2_contract2.js
├── tests
├── .env
├── hardhat.config.json
└── package.json
When I am running the 1_contract1.js from inside the scripts folder, I am getting the network not found error.
But when I am running the same file from the root folder that is app according to the diagram, it works.
Like this:
npx hardhat run scripts/1.contract1.js
So problem lies in from where you are running the script file. So try to run from the root folder.
Also if it doesn't work, please share your new configuration file.