0
0
Blockchain / Solidityprogramming~10 mins

Hardhat deployment scripts in Blockchain / Solidity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Hardhat runtime environment.

Blockchain / Solidity
const hre = require('[1]');
Drag options to blanks, or click blank then click option'
Aethers
Bhardhat
Cweb3
Dtruffle
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ethers' instead of 'hardhat' to import hre.
Trying to import 'web3' which is a different library.
2fill in blank
medium

Complete 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'
AInstance
BProvider
CSigner
DFactory
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'getContractInstance' which does not exist.
Using 'getContractSigner' which is unrelated.
3fill in blank
hard

Fix 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'
AdeployTransaction
Bdeploy
Cdeployed
Dwait
Attempts:
3 left
💡 Hint
Common Mistakes
Calling 'deploy()' again instead of 'deployed()'.
Using 'wait()' which is not a method on the contract instance.
4fill in blank
hard

Fill 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'
Aaddress
Bexit
Cdeployed
Dstop
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'deployed' instead of 'address' for the contract property.
Using 'stop' instead of 'exit' to end the process.
5fill in blank
hard

Fill 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'
Athen
Bcatch
Cexit
Dfinally
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'finally' instead of 'catch' for error handling.
Using 'stop' instead of 'exit' to end the process.