📖 Scenario: You are starting a new blockchain project. You want to write and test smart contracts easily. Two popular tools are Hardhat and Remix. Hardhat is a local development environment, and Remix is an online code editor for smart contracts.Setting up these tools correctly helps you write, test, and deploy smart contracts faster and with fewer errors.
🎯 Goal: Set up a basic Hardhat project and open Remix IDE to write a simple smart contract.You will create the initial project files, configure Hardhat, and verify that Remix is ready to use.
📋 What You'll Learn
Create a new Hardhat project folder
Initialize Hardhat with default settings
Install Hardhat dependencies
Open Remix IDE in the browser
💡 Why This Matters
🌍 Real World
Blockchain developers use Hardhat and Remix to write, test, and deploy smart contracts efficiently.
💼 Career
Knowing how to set up and use these tools is essential for blockchain developer roles and smart contract auditing.
Progress0 / 4 steps
1
Create a new Hardhat project folder
Create a new folder called hardhat-project in your workspace. Then, inside this folder, create a file named package.json with the exact content: {"name": "hardhat-project", "version": "1.0.0"}
Blockchain / Solidity
Hint
Use your terminal or command prompt to create the folder and file exactly as described.
2
Initialize Hardhat with default settings
Inside the hardhat-project folder, run the command npx hardhat and select Create a basic sample project. Accept all default options and install the recommended dependencies.
Blockchain / Solidity
Hint
Run npx hardhat in the terminal and follow the prompts to create the sample project.
3
Install Hardhat dependencies
After initializing Hardhat, install the dependencies by running npm install inside the hardhat-project folder.
Blockchain / Solidity
Hint
Run npm install to download and install all required packages.
4
Open Remix IDE in the browser
Open your web browser and go to https://remix.ethereum.org. Verify that the Remix IDE loads and shows the file explorer on the left side.
Blockchain / Solidity
Hint
Open the URL in your browser and check that the Remix interface appears with the file explorer panel.
Practice
(1/5)
1. Which of the following best describes Hardhat in blockchain development?
easy
A. A hardware device to store private keys securely
B. A local development environment to write and test smart contracts
C. An online marketplace for buying cryptocurrencies
D. A blockchain explorer to view transactions
Solution
Step 1: Understand Hardhat's purpose
Hardhat is designed as a local tool to help developers write, test, and deploy smart contracts easily on their computer.
Step 2: Compare options with Hardhat's role
Options A, B, and D describe other blockchain tools or devices, not Hardhat.
Final Answer:
A local development environment to write and test smart contracts -> Option B
Quick Check:
Hardhat = Local development tool [OK]
Hint: Hardhat runs locally for coding and testing smart contracts [OK]
Common Mistakes:
Confusing Hardhat with hardware wallets
Thinking Hardhat is an online platform
Mixing Hardhat with blockchain explorers
2. Which command correctly initializes a new Hardhat project in your terminal?
easy
A. npx hardhat
B. npx hardhat init
C. hardhat start
D. hardhat create project
Solution
Step 1: Recall Hardhat initialization command
The standard way to start a Hardhat project is by running npx hardhat which launches the setup wizard.
Step 2: Evaluate other options
Options A, B, and C are not valid Hardhat commands for project initialization.
Final Answer:
npx hardhat -> Option A
Quick Check:
Initialize Hardhat with 'npx hardhat' [OK]
Hint: Use 'npx hardhat' to start a new project setup [OK]
Common Mistakes:
Using 'hardhat create project' which is invalid
Trying 'hardhat start' instead of 'npx hardhat'
Using 'npx hardhat init' which is not a valid command
3. What will be the output when you run this Hardhat command in a new project folder?
npx hardhat compile
medium
A. Starts a local blockchain node
B. Throws an error: command not found
C. Deletes all compiled files
D. Compiles smart contracts and shows success message
Solution
Step 1: Understand the 'compile' command in Hardhat
The command npx hardhat compile compiles all smart contracts in the project and outputs success or error messages.
Step 2: Check other options
Throws an error: command not found is wrong because the command exists. Deletes all compiled files is incorrect as it does not delete files. Starts a local blockchain node is for running nodes, not compiling.
Final Answer:
Compiles smart contracts and shows success message -> Option D
Quick Check:
'npx hardhat compile' compiles contracts [OK]
Hint: Compile contracts with 'npx hardhat compile' to check code [OK]
Common Mistakes:
Expecting 'compile' to start blockchain node
Thinking 'compile' deletes files
Assuming command is invalid without setup
4. You tried to deploy a contract using Hardhat but got this error: Error: Cannot find module '@nomiclabs/hardhat-ethers' What is the most likely fix?
medium
A. Install the missing plugin with npm install --save-dev @nomiclabs/hardhat-ethers
B. Restart your computer
C. Delete the node_modules folder without reinstalling
D. Run npx hardhat compile again
Solution
Step 1: Identify the missing module error
The error says the plugin '@nomiclabs/hardhat-ethers' is missing, meaning it is not installed in the project.
Step 2: Fix by installing the missing plugin
Running npm install --save-dev @nomiclabs/hardhat-ethers adds the plugin so Hardhat can use it.
Final Answer:
Install the missing plugin with npm install --save-dev @nomiclabs/hardhat-ethers -> Option A
Quick Check:
Missing module error = install plugin [OK]
Hint: Install missing packages with npm to fix module errors [OK]
Common Mistakes:
Restarting computer without installing packages
Deleting node_modules without reinstalling
Running compile without fixing dependencies
5. You want to quickly test a simple smart contract without installing anything locally. Which tool should you use and why?
hard
A. Use Hardhat because it runs in the browser without installation
B. Use a hardware wallet to write contracts securely
C. Use Remix because it is an online editor that requires no local setup
D. Use a blockchain explorer to deploy contracts
Solution
Step 1: Identify tools for quick testing without local setup
Remix is an online IDE that lets you write, compile, and deploy contracts directly in the browser.
Step 2: Compare with other options
Hardhat requires local installation, hardware wallets store keys but don't write contracts, and blockchain explorers only view data.
Final Answer:
Use Remix because it is an online editor that requires no local setup -> Option C
Quick Check:
Quick test without install = Remix online editor [OK]
Hint: Remix runs in browser, no install needed for quick tests [OK]
Common Mistakes:
Thinking Hardhat runs in browser without install
Confusing hardware wallets with development tools
Trying to deploy contracts via blockchain explorers
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.