Lesson 2: Final notes and code repos
Final notes
Aside from refreshing my mind about data types, control structures and operators, I decided it would be worth getting to know the Hardhat framework again. I wanted to really solidify in my mind how to properly deploy and test a smart contract. It is worth noting that I had delved into these things before on Patrick Collins' youtube channel.
The full repo can be found here - https://github.com/SimSimButDifferent/L2-AssetManagement
// deploy.js
const hre = require("hardhat")
const { network } = require("hardhat")
const { developmentChains } = require("../helper-hardhat-config")
async function main() {
if (developmentChains.includes(network.name)) {
const AssetManagement =
await hre.ethers.getContractFactory("AssetManagement")
console.log("Deploying...")
const assetManagement = await AssetManagement.deploy()
console.log(`AssetManagement deployed to: ${assetManagement.target}`)
}
if (
!developmentChains.includes(network.name) &&
process.env.ETHERSCAN_API_KEY
) {
const AssetManagement =
await hre.ethers.getContractFactory("AssetManagement")
console.log("Deploying...")
const assetManagement = await AssetManagement.deploy()
console.log(`AssetManagement deployed to: ${assetManagement.target}`)
const desiredConfirmations = 2
const receipt = await assetManagement
.deploymentTransaction()
.wait(desiredConfirmations)
console.log(
`Transaction confirmed. Block number: ${receipt.blockNumber}`,
)
await hre.run("verify:etherscan", { address: assetManagement.target })
console.log("AssetManagement verified!")
console.log("--------------------------------------------------")
}
}
main().catch((error) => {
console.error(error)
process.exitCode = 1
})Last updated