Skip to content

Commit 3b47205

Browse files
committed
Add JuryDAO example under entropy folder
1 parent b48bc74 commit 3b47205

File tree

853 files changed

+163398
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

853 files changed

+163398
-0
lines changed

entropy/jurydao/.env.example

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Network Configuration (for Foundry deployment)
2+
BASE_SEPOLIA_RPC=https://sepolia.base.org
3+
CHAIN_ID=84532
4+
5+
# Pyth Entropy Contracts (Base Sepolia)
6+
PYTH_ENTROPY=0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c
7+
PYTH_PROVIDER=0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344
8+
9+
# Your Deployment Private Key (NEVER commit this!)
10+
PRIVATE_KEY=
11+
12+
# Etherscan API Key (for contract verification)
13+
ETHERSCAN_API_KEY=
14+
15+
# ========================================
16+
# Frontend Variables (VITE requires VITE_ prefix)
17+
# ========================================
18+
19+
# Network (for frontend)
20+
VITE_CHAIN_ID=84532
21+
VITE_NETWORK_NAME='Base Sepolia'
22+
VITE_RPC_URL=https://sepolia.base.org
23+
24+
# Pyth Entropy (for frontend)
25+
VITE_PYTH_ENTROPY=0x41c9e39574F40Ad34c79f1C99B66A45eFB830d4c
26+
VITE_PYTH_PROVIDER=0x6CC14824Ea2918f5De5C2f75A9Da968ad4BD6344
27+
28+
# Deployed Contract Addresses (fill after deployment)
29+
VITE_GOVERNANCE_TOKEN=
30+
VITE_JUROR_REGISTRY=
31+
VITE_GOVERNOR_SORTITION=

entropy/jurydao/.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
.env
15+
broadcast/
16+
cache/
17+
out/
18+
node_modules/
19+
.env.bak
20+
21+
22+
# Editor directories and files
23+
.vscode/*
24+
!.vscode/extensions.json
25+
.idea
26+
.DS_Store
27+
*.suo
28+
*.ntvs*
29+
*.njsproj
30+
*.sln
31+
*.sw?

entropy/jurydao/.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std
4+
[submodule "lib/pyth-sdk-solidity"]
5+
path = lib/pyth-sdk-solidity
6+
url = https://github.com/pyth-network/pyth-sdk-solidity
7+
[submodule "lib/openzeppelin-contracts"]
8+
path = lib/openzeppelin-contracts
9+
url = https://github.com/OpenZeppelin/openzeppelin-contracts

entropy/jurydao/Readme.md

Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
<div align="center">
2+
3+
![JuryDAO Logo](./assets/logo.png)
4+
5+
# 🏛️ JuryDAO
6+
### Decentralized Governance Through Random Jury Selection
7+
8+
[![Solidity](https://img.shields.io/badge/Solidity-%5E0.8.20-363636?logo=solidity)](https://soliditylang.org)
9+
[![React](https://img.shields.io/badge/React-18.3.1-61DAFB?logo=react)](https://react.dev)
10+
[![Foundry](https://img.shields.io/badge/Built%20with-Foundry-orange)](https://book.getfoundry.sh)
11+
[![Pyth Network](https://img.shields.io/badge/Powered%20by-Pyth%20Entropy-7C3AED)](https://entropy.pyth.network)
12+
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](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+
![Home](./assets/home.png)
42+
Landing with clear CTAs and project overview.
43+
44+
### 📊 Dashboard
45+
![Dashboard](./assets/dashboard.png)
46+
Track proposals, states, juror slots, and timelines.
47+
48+
### ✍️ Create Proposal
49+
![Create](./assets/create.png)
50+
Proposers set title, details, jury size, and deadlines.
51+
52+
### 👨‍⚖️ Juror Registration
53+
![Juror](./assets/juror.png)
54+
Register eligibility (e.g., 100 DGOV requirement).
55+
56+
### ⚙️ Admin Panel
57+
![Admin](./assets/admin.png)
58+
Manage fees, funds, and system parameters.
59+
60+
### 📜 Proposal Details
61+
![Proposal](./assets/proposal.png)
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>

entropy/jurydao/assets/admin.png

1.07 MB
Loading

entropy/jurydao/assets/create.png

1.21 MB
Loading
172 KB
Loading

entropy/jurydao/assets/home.png

1.6 MB
Loading

entropy/jurydao/assets/juror.png

1.08 MB
Loading

entropy/jurydao/assets/logo.png

60.3 KB
Loading

0 commit comments

Comments
 (0)