Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the Hardhat runtime environment.
Blockchain / Solidity
const hre = require('[1]');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ethers' instead of 'hardhat' to import hre.
Trying to import 'web3' which is a different library.
✗ Incorrect
The Hardhat runtime environment is imported using require('hardhat').
2fill in blank
mediumComplete the code to get the contract factory for deployment.
Blockchain / Solidity
const Contract = await hre.ethers.getContract[1]('MyContract');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'getContractInstance' which does not exist.
Using 'getContractSigner' which is unrelated.
✗ Incorrect
To deploy a contract, you get its factory using getContractFactory.
3fill in blank
hardFix the error in the deployment code to wait for the contract to be deployed.
Blockchain / Solidity
const contract = await Contract.deploy();
await contract.[1](); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling 'deploy()' again instead of 'deployed()'.
Using 'wait()' which is not a method on the contract instance.
✗ Incorrect
After calling deploy(), you wait for deployment with deployed().
4fill in blank
hardFill both blanks to log the deployed contract address and exit the script.
Blockchain / Solidity
console.log('Contract deployed to:', contract.[1]); process.[2](0);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'deployed' instead of 'address' for the contract property.
Using 'stop' instead of 'exit' to end the process.
✗ Incorrect
The deployed contract address is accessed with address. To end the script, use process.exit(0).
5fill in blank
hardFill all three blanks to handle errors and run the main deployment function.
Blockchain / Solidity
async function main() {
// deployment code
}
main()
.[1](() => process.exit(0))
.[2]((error) => {
console.error(error);
process.[3](1);
}); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'finally' instead of 'catch' for error handling.
Using 'stop' instead of 'exit' to end the process.
✗ Incorrect
Promises use then for success and catch for errors. To exit with error code, use process.exit(1).