|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +# 🏛️ JuryDAO |
| 6 | +### Decentralized Governance Through Random Jury Selection |
| 7 | + |
| 8 | +[](https://soliditylang.org) |
| 9 | +[](https://react.dev) |
| 10 | +[](https://book.getfoundry.sh) |
| 11 | +[](https://entropy.pyth.network) |
| 12 | +[](LICENSE) |
| 13 | + |
| 14 | +**[🚀 Quick Start](#installation) • [📖 Features](#-features) • [🎮 Usage](#-usage-guide) • [🧪 Tests](#-testing)** |
| 15 | + |
| 16 | +A solo Web3 project by a developer from IIT Roorkee 🇮🇳 |
| 17 | +</div> |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## 🎯 What is JuryDAO? |
| 22 | +JuryDAO is a decentralized governance framework that replaces all-hands voting with provably random juries per proposal, improving fairness, participation, and efficiency. It uses verifiable randomness (VRF) to select a small jury for each proposal, compensates voters for gas, and finalizes outcomes transparently. The design combats whale dominance, reduces voter fatigue, and makes governance more reliable and scalable. |
| 23 | + |
| 24 | +### The Problem |
| 25 | +- Whale dominance: large token holders control outcomes |
| 26 | +- Low participation: most members don't vote consistently |
| 27 | +- Time cost: reviewing every proposal is exhausting |
| 28 | + |
| 29 | +### The Solution |
| 30 | +- Random juries per proposal (equal selection chance) |
| 31 | +- Verifiable randomness via Pyth Entropy VRF |
| 32 | +- Gas refunds for jurors to encourage participation |
| 33 | +- Automatic callbacks to progress proposals reliably |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## 🖼️ Screenshots |
| 38 | +<div align="center"> |
| 39 | + |
| 40 | +### 🏠 Home |
| 41 | + |
| 42 | +Landing with clear CTAs and project overview. |
| 43 | + |
| 44 | +### 📊 Dashboard |
| 45 | + |
| 46 | +Track proposals, states, juror slots, and timelines. |
| 47 | + |
| 48 | +### ✍️ Create Proposal |
| 49 | + |
| 50 | +Proposers set title, details, jury size, and deadlines. |
| 51 | + |
| 52 | +### 👨⚖️ Juror Registration |
| 53 | + |
| 54 | +Register eligibility (e.g., 100 DGOV requirement). |
| 55 | + |
| 56 | +### ⚙️ Admin Panel |
| 57 | + |
| 58 | +Manage fees, funds, and system parameters. |
| 59 | + |
| 60 | +### 📜 Proposal Details |
| 61 | + |
| 62 | +Selected jurors vote; results shown in real time. |
| 63 | + |
| 64 | +</div> |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +## ✨ Features |
| 69 | + |
| 70 | +### 🔮 Smart Contracts |
| 71 | +- Provably random jury selection via Pyth Entropy VRF |
| 72 | +- Automatic selection callbacks within ~60 seconds |
| 73 | +- Gas refunds to voters (e.g., 0.0005 ETH per vote) |
| 74 | +- Flexible voting periods (1 hour to 30 days) |
| 75 | +- Fisher–Yates shuffle for unbiased selection |
| 76 | +- Owner-controlled fee management and safe withdrawals |
| 77 | + |
| 78 | +### 🎨 Frontend |
| 79 | +- Wallet integration (e.g., MetaMask) and network checks |
| 80 | +- Real-time state updates and explorer links |
| 81 | +- Responsive UI with animations and toasts |
| 82 | +- Clear flows for proposers, jurors, and admins |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## 🏗️ Tech Stack |
| 87 | + |
| 88 | +| Category | Technology | |
| 89 | +|-------------------|----------------------------------| |
| 90 | +| Smart Contracts | Solidity 0.8.20, Foundry | |
| 91 | +| Randomness | Pyth Network Entropy | |
| 92 | +| Frontend | React 18, Vite, TypeScript | |
| 93 | +| Styling | Tailwind CSS, Framer Motion | |
| 94 | +| Web3 | Ethers.js v6 | |
| 95 | +| Network | Base Sepolia (Testnet) | |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## 📦 Installation |
| 100 | + |
| 101 | +### Prerequisites |
| 102 | +- Node.js v18+ and npm |
| 103 | +- Foundry (forge, cast, anvil) |
| 104 | + |
| 105 | +Check versions: |
| 106 | +```bash |
| 107 | +node --version |
| 108 | +forge --version |
| 109 | +``` |
| 110 | + |
| 111 | +Install Foundry: |
| 112 | +```bash |
| 113 | +curl -L https://foundry.paradigm.xyz | bash |
| 114 | +foundryup |
| 115 | +``` |
| 116 | + |
| 117 | +### Clone |
| 118 | +```bash |
| 119 | +git clone https://github.com/yourusername/jurydao.git |
| 120 | +cd jurydao |
| 121 | +``` |
| 122 | + |
| 123 | +### Install Dependencies |
| 124 | +```bash |
| 125 | +npm install |
| 126 | +forge install |
| 127 | +``` |
| 128 | + |
| 129 | +### Environment Setup |
| 130 | +Create a `.env` in project root: |
| 131 | +```ini |
| 132 | +# Private key (0x-prefixed); DO NOT COMMIT THIS FILE |
| 133 | +PRIVATE_KEY=0xYOUR_PRIVATE_KEY |
| 134 | + |
| 135 | +# Base Sepolia RPC |
| 136 | +RPC_URL=https://sepolia.base.org |
| 137 | + |
| 138 | +# Basescan API key (for contract verification) |
| 139 | +ETHERSCAN_API_KEY=YOUR_BASESCAN_KEY |
| 140 | + |
| 141 | +# Pyth Entropy (Base Sepolia) |
| 142 | +ENTROPY_ADDRESS=0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c |
| 143 | +ENTROPY_PROVIDER=0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344 |
| 144 | + |
| 145 | +# Frontend-populated by deploy script (fill after deploy) |
| 146 | +VITE_GOVERNANCE_TOKEN= |
| 147 | +VITE_JUROR_REGISTRY= |
| 148 | +VITE_GOVERNOR_SORTITION= |
| 149 | +``` |
| 150 | + |
| 151 | +--- |
| 152 | + |
| 153 | +## 🚀 Deployment |
| 154 | + |
| 155 | +### Contracts |
| 156 | +If you have a helper script: |
| 157 | +```bash |
| 158 | +chmod +x redeploy.sh |
| 159 | +./redeploy.sh |
| 160 | +``` |
| 161 | +The script should: |
| 162 | +1. Compile contracts |
| 163 | +2. Deploy to Base Sepolia |
| 164 | +3. Verify on Basescan |
| 165 | +4. Write deployed addresses into `.env` |
| 166 | + |
| 167 | +### Frontend |
| 168 | +```bash |
| 169 | +npm run dev |
| 170 | +``` |
| 171 | +Open http://localhost:5173 |
| 172 | + |
| 173 | +--- |
| 174 | + |
| 175 | +## 📚 Architecture |
| 176 | + |
| 177 | +### Flow (Mermaid) |
| 178 | +```mermaid |
| 179 | +graph TD |
| 180 | + A[User Creates Proposal] --> B[Pay BASE_FEE × MULTIPLIER] |
| 181 | + B --> C[Request Pyth Entropy] |
| 182 | + C --> D[Pyth Generates Random Number] |
| 183 | + D --> E[entropyCallback Triggered] |
| 184 | + E --> F[Fisher–Yates Shuffle] |
| 185 | + F --> G[Jury Selected] |
| 186 | + G --> H[Proposal Active] |
| 187 | + H --> I[Selected Jurors Vote] |
| 188 | + I --> J[Proposal Executed] |
| 189 | +``` |
| 190 | + |
| 191 | +### Core Interfaces (example) |
| 192 | +```solidity |
| 193 | +// Create a proposal with ETH fee |
| 194 | +function createProposal( |
| 195 | + string memory title, |
| 196 | + string memory description, |
| 197 | + uint256 jurySize, |
| 198 | + uint256 votingPeriodSeconds |
| 199 | +) external payable; |
| 200 | +
|
| 201 | +// Pyth Entropy callback (internal) |
| 202 | +function entropyCallback( |
| 203 | + uint64 sequenceNumber, |
| 204 | + address provider, |
| 205 | + bytes32 randomNumber |
| 206 | +) internal; |
| 207 | +
|
| 208 | +// Vote (jurors only) with gas refund |
| 209 | +function vote(uint256 id, bool support) external; |
| 210 | +
|
| 211 | +// Finalize after the end time |
| 212 | +function execute(uint256 id) external; |
| 213 | +``` |
| 214 | + |
| 215 | +### Fee Model (example) |
| 216 | +- Total cost ≈ (BASE_FEE × MULTIPLIER) + (jurySize × GAS_REFUND) |
| 217 | +- Example (5 jurors): (0.01 × 3) + (5 × 0.0005) = 0.0325 ETH |
| 218 | + |
| 219 | +--- |
| 220 | + |
| 221 | +## 🎮 Usage Guide |
| 222 | + |
| 223 | +### Juror |
| 224 | +1. Register eligibility (meets token threshold, e.g., 100 DGOV) |
| 225 | +2. If selected, open the proposal page |
| 226 | +3. Cast vote and receive gas refund |
| 227 | + |
| 228 | +### Proposer |
| 229 | +1. Create proposal with title, description, jury size, deadline |
| 230 | +2. Pay required ETH; wait for automatic jury selection |
| 231 | +3. Monitor votes and finalize after end time |
| 232 | + |
| 233 | +--- |
| 234 | + |
| 235 | +## 🧪 Testing |
| 236 | +```bash |
| 237 | +forge test -vvv |
| 238 | +forge test --match-contract GovernorSortitionTest -vvv |
| 239 | +forge test --gas-report |
| 240 | +forge coverage |
| 241 | +``` |
| 242 | + |
| 243 | +--- |
| 244 | + |
| 245 | +## 🐛 Troubleshooting |
| 246 | + |
| 247 | +- "Insufficient funds" on deploy or callback |
| 248 | + Use a Base Sepolia faucet to top up test ETH. |
| 249 | + |
| 250 | +- "Jury not selected" after creation |
| 251 | + Check the Pyth Entropy explorer for request/callback status and ensure fee multiplier covered callback gas. |
| 252 | + |
| 253 | +- Wallet not connecting |
| 254 | + Add Base Sepolia network: |
| 255 | + - RPC: https://sepolia.base.org |
| 256 | + - Chain ID: 84532 |
| 257 | + - Explorer: https://sepolia.basescan.org |
| 258 | + |
| 259 | +--- |
| 260 | + |
| 261 | +## 📈 Roadmap |
| 262 | +- [x] Core governance (propose, select jury, vote, execute) |
| 263 | +- [x] Pyth Entropy integration |
| 264 | +- [x] Gas-optimized contracts |
| 265 | +- [x] Responsive animated UI |
| 266 | +- [ ] Proposal delegation |
| 267 | +- [ ] Multi-chain deployments |
| 268 | +- [ ] Decentralized storage for proposals (IPFS) |
| 269 | +- [ ] Analytics dashboard |
| 270 | +- [ ] Mobile app |
| 271 | + |
| 272 | +--- |
| 273 | + |
| 274 | +## 🤝 Contributing |
| 275 | +1. Fork the repo |
| 276 | +2. Create a branch: `git checkout -b feature/awesome` |
| 277 | +3. Commit: `git commit -m "feat: add awesome thing"` |
| 278 | +4. Push: `git push origin feature/awesome` |
| 279 | +5. Open a Pull Request |
| 280 | + |
| 281 | +--- |
| 282 | + |
| 283 | +## 📄 License |
| 284 | +MIT — see [LICENSE](./LICENSE) |
| 285 | + |
| 286 | +--- |
| 287 | + |
| 288 | +## 🙏 Acknowledgments |
| 289 | +- Pyth Network — verifiable randomness and tooling |
| 290 | +- Foundry — smart contract toolchain |
| 291 | +- Base — affordable L2 infrastructure |
| 292 | +- OpenZeppelin — security standards |
| 293 | + |
| 294 | +--- |
| 295 | + |
| 296 | +## 📞 Contact |
| 297 | +- GitHub: @Samarth208P |
| 298 | +- Twitter: @SamPy4X |
| 299 | + |
| 300 | + |
| 301 | +<div align="center"> |
| 302 | + |
| 303 | +### ⭐ If you like this project, consider giving it a star! |
| 304 | +Made with ❤️ and ☕ |
| 305 | +**[⬆ Back to Top](#-jurydao)** |
| 306 | + |
| 307 | +</div> |
0 commit comments