Skip to content

alfredang/pawchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐾 PawChain

Solidity React Hardhat ethers.js Vite License Tests

A full-stack Web3 smart contract dashboard with ERC20 token management, treasury controls, and dark-themed React UI β€” powered by a local Hardhat blockchain.

Report Bug Β· Request Feature


Screenshot

PawChain Dashboard

About

PawChain is a complete Web3 application featuring PawToken (PAW) β€” an ERC20 token with built-in treasury management, role-based access control, and on-chain transaction history. It comes with a sleek dark-themed React dashboard for managing all smart contract operations.

✨ Key Features

Feature Description
πŸͺ™ ERC20 Token Transfer, mint, and burn PAW tokens
🏦 Treasury Deposit/withdraw tokens from contract treasury
βš™οΈ Admin Controls Role-based access (owner/admin), pause/resume
πŸ“œ Transaction History On-chain transaction log with type tracking
πŸ”„ Account Switcher Switch between 10 local Hardhat accounts
πŸŒ™ Dark Theme Sleek dark UI with gradient accents
βœ… 12 Unit Tests Full test coverage with Hardhat + Chai

Tech Stack

Layer Technology Purpose
Smart Contract Solidity 0.8.24 ERC20 token + treasury logic
Blockchain Hardhat 2.x Local development node
Frontend React 19 Dashboard UI
Build Tool Vite 7 Fast HMR + production builds
Web3 ethers.js v6 Blockchain interaction
Styling Custom CSS Dark theme, responsive
Testing Hardhat + Chai Smart contract unit tests

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 React Dashboard              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚Dashboardβ”‚  Tokens  β”‚ Treasury β”‚ Admin  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚
β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β”‚                useContract Hook               β”‚
β”‚                 (ethers.js v6)                β”‚
└──────────────────┬──────────────────────────-β”˜
                   β”‚ JSON-RPC
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€-┐
β”‚              Hardhat Local Node               β”‚
β”‚              (http://127.0.0.1:8545)          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚           PawToken.sol (ERC20)          β”‚ β”‚
β”‚  β”‚  β€’ transfer / approve / transferFrom    β”‚ β”‚
β”‚  β”‚  β€’ mint / burn (admin)                  β”‚ β”‚
β”‚  β”‚  β€’ treasury deposit / withdraw          β”‚ β”‚
β”‚  β”‚  β€’ pause / resume                       β”‚ β”‚
β”‚  β”‚  β€’ on-chain transaction history         β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚         20 accounts Γ— 10,000 ETH each        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Project Structure

pawchain/
β”œβ”€β”€ contracts/
β”‚   └── PawToken.sol              # ERC20 token + treasury contract
β”œβ”€β”€ scripts/
β”‚   └── deploy.js                 # Deployment script
β”œβ”€β”€ test/
β”‚   └── PawToken.js               # 12 unit tests
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ vite.config.js
β”‚   β”œβ”€β”€ package.json
β”‚   └── src/
β”‚       β”œβ”€β”€ main.jsx              # Entry point
β”‚       β”œβ”€β”€ App.jsx               # Main app with sidebar navigation
β”‚       β”œβ”€β”€ styles.css            # Dark theme styles
β”‚       β”œβ”€β”€ hooks/
β”‚       β”‚   └── useContract.js    # Web3 connection & contract calls
β”‚       β”œβ”€β”€ pages/
β”‚       β”‚   β”œβ”€β”€ Dashboard.jsx     # Overview stats & account balances
β”‚       β”‚   β”œβ”€β”€ Tokens.jsx        # Transfer, mint, burn operations
β”‚       β”‚   β”œβ”€β”€ Treasury.jsx      # Deposit/withdraw treasury
β”‚       β”‚   β”œβ”€β”€ Transactions.jsx  # Transaction history table
β”‚       β”‚   └── Admin.jsx         # Access control & pause/resume
β”‚       └── contracts/
β”‚           β”œβ”€β”€ PawToken.json     # ABI (auto-generated)
β”‚           └── deployment.json   # Deploy address (auto-generated)
β”œβ”€β”€ hardhat.config.js
β”œβ”€β”€ package.json
└── README.md

Getting Started

Prerequisites

  • Node.js β‰₯ 18
  • npm β‰₯ 9

Installation

# Clone the repository
git clone https://github.com/alfredang/pawchain.git
cd pawchain

# Install smart contract dependencies
npm install

# Install frontend dependencies
cd frontend && npm install && cd ..

Running Locally

# Terminal 1: Start local blockchain
npx hardhat node

# Terminal 2: Deploy contract
npx hardhat run scripts/deploy.js --network localhost

# Terminal 3: Start dashboard
cd frontend && npm run dev

Open http://localhost:3000 to view the dashboard.

πŸ§ͺ Run Tests

npx hardhat test
  PawToken
    Deployment
      βœ” should set correct name and symbol
      βœ” should assign total supply to owner
      βœ” should set deployer as owner
    Transfers
      βœ” should transfer tokens
      βœ” should fail if insufficient balance
    Minting
      βœ” should allow admin to mint
      βœ” should reject non-admin mint
    Burning
      βœ” should burn tokens
    Treasury
      βœ” should deposit to treasury
      βœ” should withdraw from treasury
    Pause
      βœ” should pause and unpause
    Transactions
      βœ” should record transactions

  12 passing

πŸ“Š Dashboard Pages

Page Description
πŸ“Š Dashboard Token stats, contract info, recent activity, account balances with share %
πŸͺ™ Tokens Transfer between accounts, mint (admin), burn tokens
🏦 Treasury Deposit to and withdraw from contract treasury
πŸ“œ Transactions Full on-chain transaction history with type badges
βš™οΈ Admin Pause/resume contract, add/remove admin roles

πŸ” Smart Contract β€” PawToken.sol

Function Access Description
transfer Public Transfer tokens to another address
approve / transferFrom Public ERC20 allowance mechanism
mint Admin Create new tokens
burn Public Destroy tokens from caller's balance
depositToTreasury Admin Move tokens to treasury
withdrawFromTreasury Owner Withdraw tokens from treasury
addAdmin / removeAdmin Owner Manage admin roles
setPaused Owner Pause/resume all operations
getTransactions View Paginated transaction history

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Developed By

Dr Alfred Ang β€” @alfredang

Acknowledgements

  • Hardhat β€” Ethereum development environment
  • ethers.js β€” Web3 library
  • React β€” UI framework
  • Vite β€” Build tool
  • OpenZeppelin β€” Smart contract standards inspiration

⭐ Star this repo if you found it useful!

About

πŸ”— Smart contract dashboard with PawToken ERC-20 deployment, treasury management & transaction explorer. Built with Hardhat, React, Vite & ethers.js

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors