What is hardhat and how to deploy your first smart contract using it?
Here is everything you need to know
hardhat is a toolkit that helps you to create, deploy, test, and run your smart contract.
Setup
Install yarn
npm install -g yarn
yarn init -y
yarn add -D hardhat
Create your hardhat project
npx hardhat
Click Yes for everything.
Project Structure
let's go to the contract folder and write your smart contract code
Create a deploy script inside the scripts folder
Now open 2 new instances of your terminal and
In one of them run
npx hardhat node
This kicks off the local blockchain pretty dope yep
In 2nd
// This compiles your contracts
npx hardhat compile
// This 'll deploy
npx hardhat run scripts/deploy --network localhost
Save the deployed Contract address
How to interact with your Smart contract from the terminal console
npx hardhat console --network localhost
const a = await ethers.getContractFactory('NFTee')
const b = await a.attach('YOUR_DEPLOY_CONTRACT_ADDRESS')
await b.getName()
// Output: Anish