Hardhat Counter Lab
Interact with a Counter contract on your local Hardhat node. No testnet ETH needed — instant confirmations.
intermediateHardhat Local
Learning Objectives
- →Start a local Hardhat node and deploy the Counter contract
- →Connect MetaMask to localhost:8545 (chain 31337)
- →Read on-chain state: count() and owner()
- →Call increment(), decrement(), and reset() (access control)
- →Inspect Incremented / Decremented events in the transaction monitor
Prerequisites
cd hardhat && npm install- Start local node:
npm run node(keep terminal open) - Deploy contracts:
npm run deploy - Import a Hardhat private key into MetaMask and add network localhost:8545 / chain 31337
See the Local Blockchain Setup lesson for step-by-step instructions.
1
Connect to Hardhat Local
2
Load Counter Contract
Paste the Counter address from npm run deploy output.