Since it takes a while to scaffold a new hardhat project—as we all know—I've given you this code; all you have to do is follow the instructions.
git clone https://github.com/WebSculptor/hardhat-template
npm installNothing has to be touched in the hardhat.comfig.ts file because I've already configured it. This is how it appears.
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import dotenv from "dotenv";
dotenv.config();
const {
YOUR_ALCHEMY_MAINNET_API_URL,
YOUR_ALCHEMY_SEPOLIA_API_URL,
YOUR_METAMASK_ACCOUNT_PRIVATE_KEY,
YOUR_ALCHEMY_MUMBAI_API_URL,
} = process.env;
const config: HardhatUserConfig = {
solidity: "0.8.24",
gasReporter: {
gasPrice: 10000000000,
},
networks: {
hardhat: {
forking: {
url: YOUR_ALCHEMY_MAINNET_API_URL!,
},
},
sepolia: {
url: YOUR_ALCHEMY_SEPOLIA_API_URL!,
accounts: [YOUR_METAMASK_ACCOUNT_PRIVATE_KEY!],
},
mumbai: {
url: YOUR_ALCHEMY_MUMBAI_API_URL!,
accounts: [YOUR_METAMASK_ACCOUNT_PRIVATE_KEY!],
},
},
};
export default config;YOUR_ALCHEMY_MAINNET_API_URL = "<your-alchemy-mainnet-api-url>";
YOUR_ALCHEMY_SEPOLIA_API_URL = "<your-alchemy-sepolia-api-url>";
YOUR_METAMASK_ACCOUNT_PRIVATE_KEY = "<your-metamask-account-private-key>";
YOUR_ALCHEMY_MUMBAI_API_URL = "<your-alchemy-mumbai-api-url>";To obtain your alchemy keys, register here and follow the instructions.
- Go to your dashboard and click on
view all apps.
- Click on create a new app.
- Select the networks needed
- Get your API Key for the network
- Copy the HTTPS url and paste in your
.env
{
"name": "<your-project-name>",
"author": "<your-name-goes-here>",
"prod": "npx hardhat compile && npx hardhat run scripts/deploy.ts --network <your-network-name>",
}Change <your-project-name> to the name of your project and <your-name-goes-here> to your name.
Then change <your-network-name> to your desired network.
Since Sepolia is down, you can use Mumbai
- To test your contract, run this command:
npm run test- To run the hardhat node, run this command:
npm run node- To run the deploy script locally, run this command:
npm run dev- To run the deploy script to a network, run this command:
npm run prodNote: Make sure you change the <your-network-name> to the network you want to deploy to
Make sure to change the file name scripts/deploy.ts depending on which file you want to run




