0
0
Blockchain / Solidityprogramming~20 mins

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

Choose your learning style9 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.