Bird
Raised Fist0
Blockchain / Solidityprogramming~20 mins

Development tools setup (Hardhat, Remix) in Blockchain / Solidity - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Blockchain Dev Tools Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
1:30remaining
Output of Hardhat compile command
What is the expected output when you run npx hardhat compile in a new Hardhat project with a valid contracts/ folder containing Solidity files?
ACompilation finished successfully. Artifacts saved to the artifacts/ directory.
BError: No Solidity files found in the contracts/ directory.
CWarning: No network configured. Compilation skipped.
DSyntaxError: Unexpected token in Hardhat config file.
Attempts:
2 left
💡 Hint
Think about what happens when you compile Solidity contracts with Hardhat.
❓ Predict Output
intermediate
1:30remaining
Remix IDE Solidity compilation result
In Remix IDE, after writing a valid Solidity contract and clicking the Compile button, what is the expected result shown in the Compile tab?
AWarning: Remix requires a Hardhat node to compile contracts.
BError: Remix cannot connect to the Ethereum network.
CSyntaxError: Missing semicolon in Solidity code.
DCompilation successful with no errors or warnings.
Attempts:
2 left
💡 Hint
Remix compiles Solidity code directly in the browser.
🧠 Conceptual
advanced
2:00remaining
Hardhat network configuration for local testing
Which Hardhat configuration snippet correctly sets up a local network named 'localhost' on port 8545 for testing?
A"networks": { "localhost": { "url": "http://127.0.0.1:8545" } }
B"networks": { "localhost": { "host": "127.0.0.1", "port": 8545 } }
C"networks": { "localhost": { "endpoint": "http://localhost:8545" } }
D"networks": { "localhost": { "address": "127.0.0.1:8545" } }
Attempts:
2 left
💡 Hint
Hardhat uses a URL string to specify network endpoints.
🔧 Debug
advanced
2:00remaining
Identify the error in Hardhat config file
Given this Hardhat config snippet, what error will occur when running npx hardhat compile?
module.exports = {
  solidity: "0.8.18",
  networks: {
    localhost: {
      url: "http://127.0.0.1:8545",
    }
  },
  // missing comma here
  paths: {
    sources: "./contracts"
  }
};
ATypeError: Cannot read property 'url' of undefined
BSyntaxError: Unexpected token 'paths' - missing comma after networks object
CError: Solidity version 0.8.18 not supported
DNo error, compilation proceeds normally
Attempts:
2 left
💡 Hint
Check punctuation between object properties in JavaScript objects.
🚀 Application
expert
3:00remaining
Deploying a contract using Hardhat script
Which script correctly deploys a Solidity contract named MyToken using Hardhat and logs the deployed address?
A
async function main() {
  const MyToken = await ethers.getContractFactory("MyToken");
  const token = MyToken.deploy();
  console.log(`Deployed to: ${token.address}`);
}

main().catch(console.error);
B
async function main() {
  const token = await ethers.deployContract("MyToken");
  console.log(`Deployed to: ${token.address}`);
}

main();
C
async function main() {
  const MyToken = await ethers.getContractFactory("MyToken");
  const token = await MyToken.deploy();
  await token.deployed();
  console.log(`Deployed to: ${token.address}`);
}

main().catch(console.error);
D
function main() {
  const MyToken = ethers.getContractFactory("MyToken");
  const token = MyToken.deploy();
  console.log(`Deployed to: ${token.address}`);
}

main();
Attempts:
2 left
💡 Hint
Remember to await deployment and the deployed promise before accessing the address.

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

  1. 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.
  2. Step 2: Compare options with Hardhat's role

    Options A, B, and D describe other blockchain tools or devices, not Hardhat.
  3. Final Answer:

    A local development environment to write and test smart contracts -> Option B
  4. 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

  1. Step 1: Recall Hardhat initialization command

    The standard way to start a Hardhat project is by running npx hardhat which launches the setup wizard.
  2. Step 2: Evaluate other options

    Options A, B, and C are not valid Hardhat commands for project initialization.
  3. Final Answer:

    npx hardhat -> Option A
  4. 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

  1. 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.
  2. 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.
  3. Final Answer:

    Compiles smart contracts and shows success message -> Option D
  4. 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

  1. 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.
  2. Step 2: Fix by installing the missing plugin

    Running npm install --save-dev @nomiclabs/hardhat-ethers adds the plugin so Hardhat can use it.
  3. Final Answer:

    Install the missing plugin with npm install --save-dev @nomiclabs/hardhat-ethers -> Option A
  4. 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

  1. 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.
  2. 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.
  3. Final Answer:

    Use Remix because it is an online editor that requires no local setup -> Option C
  4. 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 unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard