A blockchain-powered charity game where you feed a piggy bank with crypto donations and earn badges for your contributions! Built with Hardhat local blockchain, MetaMask, and real blockchain transactions.
- Interactive piggy bank game with animations
- Real blockchain donations on local Hardhat network
- Badge system (1, 2, 3 badges for milestones)
- Celebration animations and confetti
- Progress tracking and statistics
- Full Hardhat development environment
- Node.js installed (v16 or higher)
- MetaMask browser extension
- Git (optional, for cloning)
# Open PowerShell/Command Prompt
# Navigate to your project folder
cd D:\Donation-sitenpm installnpm run nodeWhat happens:
- Starts local blockchain on port 8545
- Creates 20 test accounts with 10,000 ETH each
- Shows private keys for each account
- KEEP THIS TERMINAL OPEN!
Example output:
Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/
Accounts
========
Account #0: 0xf39...66 (10000 ETH)
Private Key: 0xac..80
Account #1: 0x70..C8 (10000 ETH)
Private Key: 0x59..0d
- Copy a private key from the terminal (starts with
0x) - Open MetaMask in your browser
- Click account icon (top right)
- Click "Import Account"
- Paste the private key and click "Import"
- You now have 10,000 test ETH!
- In MetaMask, click the network dropdown (top center)
- Click "Add Network" → "Add a network manually"
- Enter these details:
- Network Name:
Hardhat Local - RPC URL:
http://127.0.0.1:8545 - Chain ID:
31337 - Currency Symbol:
ETH - Block Explorer URL: (leave empty)
- Network Name:
- Click "Save"
# Open a NEW terminal window
# Navigate to project folder
cd D:\Donation-site
# Deploy the contract
npm run deploy:localhostWhat happens:
- Deploys DonationPiggy.sol contract
- Shows contract address
- Copy this address for later use
Example output:
DonationPiggy deployed to: 0x5FbDB2315678afecb367f032d93F642f64180aa3
# In the SAME terminal as Step 6 (or open another)
npx serve -l 5500 .What happens:
- Starts web server on port 5500
- Serves your HTML/CSS/JS files
- KEEP THIS TERMINAL OPEN TOO!
Example output:
Serving!
- Local: http://localhost:5500
- Network: http://192.168.0.103:5500
- Open your browser
- Go to:
http://localhost:5500/trial1.html
- Click "CONNECT WALLET" button
- Approve connection in MetaMask
- Make sure you're on "Hardhat Local" network
- Enter recipient address:
- Use the contract address from Step 6, OR
- Use any valid Ethereum address (0x...)
- Click donate buttons (5, 20, or 50 coins)
- Approve transactions in MetaMask
- Watch the piggy fill up and burst!