How I Finally Learnt Foundry After Missing Two Assessments

My week 3 experience at web3bridge
If you have been watching my journey in Web3, then you must know that I have been under training at Web3Bridge in Solidity. That day had been the most stressful, last week. (Strange thing? We have just started.)
Why was this week such a rollercoaster?
Well, it was the problem of installing Foundry and Hardhat, and that was the confusion that made me miss a class exercise and an assignment because I couldn’t turn in my answer before the deadline. Heartbreaking. But rather than sit down and let the setback get the better of me, I went ahead and learned how to do it, so now you’ll hear me narrating so that you don’t get trapped in the same pit.
Let me start out with one golden rule given by my tutor:
“Learn to read docs, enjoy it. It’s your best friend.”
Hardhat Installation (The No-Village-People Method)
I tried doing this via Yarn for it quite felt as if the Village people followed me all the way to Ikorodu; so, I stuck with npm, and it just worked.
Step-wise procedure of installation:
- Set Up Your Project
Open VS Code (or any text editor you prefer)
Create or open a folder for your Hardhat project
Open your terminal and run:
npm install - save-dev hardhat
npx hardhat
Choose a TypeScript project setup (Yes, I recommend it. No, I’m not forcing you. Actually, I am.)
Keep pressing Enter until the setup completes
Configure Your Environment
Create a .env
file in the root of your project and include:
PRIVATE_KEY="bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
ALFAJORES_URL_KEY= "https://alfajores-forno.celo-testnet.org"
CELO_MNEMONIC="good good good good good good good good good good good good"
Keep your keys private! Don’t share them with anyone. Ever. As well as your mnemonic phrase which you can get from you metamask
To add the Celo Alfajores Testnet to MetaMask:
Network Name: Celo Alfajores Testnet
New RPC URL: https://alfajores-forno.celo-testnet-us1.celo.org
Chain ID: 44787
Currency Symbol: CELO
Block Explorer URL: https://alfajores.celoscan.io
Then, claim some testnet CELO tokens here: https://faucet.celo.org/alfajores
Now install the dotenv
package:
npm add dotenv
Edit & Configure Your Project
Inside the contracts/
folder, rename Lock.sol
to Storage.sol
or your preferred contract.
Then update your hardhat.config.ts
like this:
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
require("dotenv").config();
const { PRIVATE_KEY, CELO_TESTNET_RPC_URL } = process.env;
const config: HardhatUserConfig = {
solidity: "0.8.28",
networks: {
alfajores: {
url: ALFAJORES_URL_KEY,
accounts: {
mnemonic: CELO_MNEMONIC,
path: "m/44'/52752'/0'/0",
},
chainId: 44787,
},
},
};
export default config;
Compile and Deploy
To compile:
npx hardhat compile
If you run into any errors, check the Solidity version in your contract or configuration.
To deploy and verify:
bashCopyEditnpx hardhat ignition deploy ignition/modules/Lock.ts --network alfajores --verify
My deployment worked, but verification failed. 😢
If you know how to solve that, please drop a comment and help a brother out.
Big thanks to web3bridge, my classmates, and Ibrahim, who is a friend I made here at web3bridge.
Subscribe to my newsletter
Read articles from Sherif Lawal directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
