A React + Hardhat project for learning blockchain development.
- Node.js 18+
- MetaMask browser extension
npm installnpx hardhat nodeThis starts a local Ethereum node at http://127.0.0.1:8545 with 20 test accounts, each with 10,000 ETH.
npx hardhat compile
npx hardhat run scripts/deploy.cjs --network localhostThe deploy script automatically updates src/contracts/Greeter.ts with the contract address and ABI.
npm run devOpen http://localhost:5173 in your browser.
- Open MetaMask
- Click network dropdown (top left)
- Click "Add network" then "Add a network manually"
- Enter:
- Network Name:
Hardhat - RPC URL:
http://127.0.0.1:8545 - Chain ID:
31337 - Currency Symbol:
ETH
- Network Name:
- Click Save
- Click your account icon in MetaMask
- Click "Add account or hardware wallet"
- Click "Import account"
- Paste private key:
0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 - Click Import
You now have an account with 10,000 test ETH.
contracts/ Solidity smart contracts
scripts/ Deployment scripts
src/
contracts/ Auto-generated contract ABIs
App.tsx React frontend
wagmi.ts Blockchain connection config
| Command | Description |
|---|---|
npx hardhat node |
Start local blockchain |
npx hardhat compile |
Compile contracts |
npx hardhat run scripts/deploy.cjs --network localhost |
Deploy to local |
npm run dev |
Start React dev server |
This is normal. MetaMask can't fetch USD prices for test networks. Your ETH balance is still there.
- In MetaMask, go to Settings > Advanced
- Click "Clear activity tab data"
- Try the transaction again
This happens when you restart the Hardhat node but MetaMask has cached old nonces.
Re-deploy the contract after restarting Hardhat node:
npx hardhat run scripts/deploy.cjs --network localhost