0
0
Blockchain / Solidityprogramming~5 mins

Hardhat deployment scripts in Blockchain / Solidity - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main purpose of a Hardhat deployment script?
A Hardhat deployment script automates the process of deploying smart contracts to a blockchain network, making it easier and repeatable.
Click to reveal answer
beginner
In a Hardhat deployment script, what does the function hre.ethers.getContractFactory do?
It creates a contract factory object that allows you to deploy new instances of a smart contract.
Click to reveal answer
beginner
Why do we use await when deploying contracts in Hardhat scripts?
Because deploying contracts is an asynchronous operation that takes time, await ensures the script waits for deployment to finish before moving on.
Click to reveal answer
intermediate
What is the role of the main function in a Hardhat deployment script?
The main function contains the deployment logic and is executed to deploy contracts. It is usually wrapped in a try-catch block to handle errors.
Click to reveal answer
intermediate
How can you pass constructor arguments to a contract during deployment in a Hardhat script?
You pass constructor arguments as parameters to the deploy method of the contract factory, e.g., Contract.deploy(arg1, arg2).
Click to reveal answer
What does hre stand for in Hardhat deployment scripts?
AHardhat Runtime Environment
BHardhat Remote Execution
CHardhat Resource Engine
DHardhat React Extension
Which keyword is used to wait for a contract deployment to complete in a Hardhat script?
Aawait
Bdefer
Cwait
Dpause
How do you handle errors in a Hardhat deployment script?
AUsing <code>if-else</code> statements
BUsing <code>try-catch</code> blocks
CUsing <code>switch-case</code>
DNo error handling is needed
What command runs a Hardhat deployment script?
Ahardhat deploy
Bnpm start <script>
Cnpx hardhat run <script>
Dnode deploy.js
Where do you usually specify the network to deploy to in Hardhat?
AIn the deployment script
BIn the package.json file
CIn the smart contract code
DIn the Hardhat config file
Explain the steps to write a basic Hardhat deployment script for a smart contract.
Think about how you prepare, deploy, and handle errors in the script.
You got /5 concepts.
    Describe how constructor arguments are passed during contract deployment in Hardhat scripts.
    Focus on the deploy method call and its parameters.
    You got /3 concepts.