A full-stack Web3 smart contract dashboard with ERC20 token management, treasury controls, and dark-themed React UI β powered by a local Hardhat blockchain.
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.
| 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 |
| 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 |
βββββββββββββββββββββββββββββββββββββββββββββββ
β 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 β
ββββββββββββββββββββββββββββββββββββββββββββββββ
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
- Node.js β₯ 18
- npm β₯ 9
# 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 ..# 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 devOpen http://localhost:3000 to view the dashboard.
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
| 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 |
| 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 |
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Dr Alfred Ang β @alfredang
- 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!
