Web3 QA Hub

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

  1. cd hardhat && npm install
  2. Start local node: npm run node (keep terminal open)
  3. Deploy contracts: npm run deploy
  4. 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.