Blockchain-based e-Participatory Budgeting system with an integrated token economy for conflict management arising from corruption investigations. Built as a proof-of-concept for Estonia's e-PB system.
| Layer | Technology |
|---|---|
| Blockchain | Solidity 0.8.28, OpenZeppelin v5, Hardhat |
| Backend | Node.js, Express, TypeScript, ethers.js v6 |
| Frontend | Next.js 14 (App Router), React 18, Tailwind CSS, Recharts |
| Storage | IPFS via Pinata (mock in-memory store for PoC) |
| Identity | Simulated Estonian e-ID (Isikukood) verification |
| Wallet | MetaMask (Hardhat local network, chain ID 31337) |
| Containerization | Docker, Docker Compose |
| Token Standard | ERC-20 (ePBU utility token), ERC-20 non-transferable (Governance), ERC-721 Soulbound (Reputation) |
┌──────────────────────────────────────────────────────────────────┐
│ Frontend (Next.js 14) │
│ Home │ Register │ Ideas │ Voting │ Feedback │ Rewards & Transit │
│ Fund Tracking │ Disputes │ Metrics │ Admin Panel │
├──────────────────────────────────────────────────────────────────┤
│ Backend (Express + TypeScript) │
│ Auth │ PB Lifecycle │ Fund Tracking │ Disputes │ Redemption │
│ Metrics │ Admin │ Token Rewards (mintReward) │
├──────────────────────────────────────────────────────────────────┤
│ Smart Contracts (Solidity) │
│ ePBUtilityToken │ GovernanceToken │ ReputationSBT │
│ CitizenRegistry │ PBLifecycle │ FundAllocation │
│ DisputeRegistry │ MediationEngine │ ArbitrationDAO │
│ TokenRedemption │
├──────────────────────────────────────────────────────────────────┤
│ Hardhat Local Network (31337) │
└──────────────────────────────────────────────────────────────────┘
| Contract | Purpose |
|---|---|
ePBUtilityToken |
ERC-20 participation reward token (SUBMIT=10, DISCUSS=5, VOTE=5, FEEDBACK=3, DISPUTE=50 ePBU) |
GovernanceToken |
Non-transferable ERC-20 for arbitration voting weight |
ReputationSBT |
Soulbound ERC-721 badges for milestones |
CitizenRegistry |
Role-based access with simulated Estonian e-ID (Isikukood) |
PBLifecycle |
7-stage PB process management |
FundAllocation |
Milestone-based fund release with audit trail |
DisputeRegistry |
Dispute filing with token staking and evidence |
MediationEngine |
Automated first-pass resolution |
ArbitrationDAO |
DAO-based arbitration with whistleblower rewards |
TokenRedemption |
Redeem ePBU tokens for public transport discount vouchers |
The system supports 5 Estonian municipalities:
- Tallinn
- Tartu
- Rapla
- Saue
- Lääne-Nigula
| Role | Access |
|---|---|
| Citizen | Submit ideas, discuss, vote, give feedback, redeem rewards |
| City Council | Start/advance PB cycles, manage ideas, create projects |
| Expert Evaluator | Score and evaluate submitted ideas |
| Auditor | Monitor fund allocation and milestone approvals |
| Mediator | Manage and resolve disputes |
All roles require Estonian ID (Isikukood) verification.
Citizens earn ePBU tokens for participating:
| Action | Reward |
|---|---|
| Submit idea | 10 ePBU |
| Post comment | 5 ePBU |
| Cast vote | 5 ePBU |
| Give feedback | 3 ePBU |
| Validated dispute | 50 ePBU |
Earned tokens can be redeemed for ISIC-style discounts on Estonian regional transport:
| Route | Cost | Discount |
|---|---|---|
| Tallinn-Tartu Express (single) | 15 ePBU | 50% off |
| Tallinn-Tartu Express (10-trip pass) | 100 ePBU | 50% off |
| Tallinn-Parnu Regional (single) | 12 ePBU | 50% off |
| Tartu-Viljandi Local (single) | 8 ePBU | 50% off |
| Tallinn City Transport (1-day pass) | 20 ePBU | Free |
git clone https://github.com/mustafa-1367/epb-system.git
cd epb-system/epb-system
docker compose up --buildThis starts all 3 services automatically:
- Hardhat node on port 8545 (compiles + deploys 10 contracts)
- Backend API on port 3001
- Frontend on port 3000
Open http://localhost:3000 in your browser.
- Node.js 18+
- MetaMask browser extension
cd epb-system
npm install
# Compile contracts
npx hardhat compile
# Run tests
npx hardhat test
# Start local node
npx hardhat node
# Deploy (in another terminal)
npx hardhat run deploy/deploy.ts --network localhostcd backend
npm install
npm run devcd frontend
npm install
npm run devVisit http://localhost:3000
- Add Hardhat network: RPC
http://127.0.0.1:8545, Chain ID31337 - Import Hardhat test accounts using private keys from the Hardhat node output
npx hardhat run simulation/evaluate.ts --network hardhatRuns a full PB cycle with 55 citizens and 5 corruption scenarios.
- Budget Determination - Municipality sets total PB budget
- Idea Submission - Citizens submit proposals (earn 10 ePBU)
- Public Discussion - Comment and like/unlike ideas (earn 5 ePBU)
- Expert Evaluation - Committee of experts score ideas (-100 to 100)
- Voting - Citizens vote, max 3 per cycle (earn 5 ePBU)
- Implementation - Milestone-based fund release with audit trail
- Feedback - Citizens rate implemented proposals (earn 3 ePBU)
Dispute Filed (stake ePBU tokens)
│
▼
MediationEngine (automated rules check)
│
├── Auto-resolved → RESOLVED
│
├── Committee vote (≥2/3 supermajority)
│ ├── Validated → RESOLVED + stake returned + 50 ePBU reward
│ ├── Rejected → RESOLVED + stake slashed
│ └── Deadlocked → ESCALATED
│
└── ArbitrationDAO (5 random arbitrators)
├── Validated → penalties executed + whistleblower reward
├── Rejected → stake slashed
└── Deadlocked → full DAO vote
The simulation measures:
- Detection rate: % of corruption scenarios detected
- Resolution time: Time from filing to resolution
- Participation rate: Actions per citizen
- Token distribution fairness: Gini coefficient
- Fund tracking accuracy: Blockchain provides 100% accuracy
- Transparency index: Composite score (event coverage, fund traceability, dispute resolution, participation openness)
epb-system/
├── contracts/ # 10 Solidity smart contracts
├── test/ # Hardhat tests
├── deploy/ # Deployment scripts
├── simulation/ # Evaluation simulation
├── docker/ # Docker configuration
│ ├── hardhat/ # Blockchain node container
│ ├── backend/ # API server container
│ └── frontend/ # Web app container
├── docker-compose.yml # One-command deployment
├── backend/
│ └── src/
│ ├── routes/ # API endpoints (auth, pb, disputes, redemption, admin, metrics)
│ ├── services/ # Blockchain service (ethers.js)
│ ├── middleware/ # Auth middleware
│ └── utils/ # IPFS utilities
└── frontend/
└── src/
├── app/ # Next.js pages (13 routes)
├── components/ # UI + feature components
├── context/ # Role & verification contexts
├── hooks/ # Wallet hook (MetaMask)
└── lib/ # API client + utilities
ISC