Smart Contracts Overview
CredDAO consists of two Anchor programs that work together to enable reputation-weighted governance on Solana.
Architecture
Programs
| Program | Address | Description |
|---|---|---|
| CredDAO | CreDDAo111111111111111111111111111111111111 | Core governance logic |
| FairScore Oracle | Faire11111111111111111111111111111111111111 | Reputation scoring system |
Key Features
CredDAO Program
The main governance contract handles:
- DAO initialization - Set up governance parameters
- Member registration - Onboard new members with initial scores
- Proposal lifecycle - Create, vote, finalize, execute
- Delegation - Delegate voting power to trusted members
- Time-locks - Tier-based execution delays
FairScore Oracle
The reputation oracle manages:
- Score initialization - Create reputation profiles
- Score updates - Refresh scores from authorized sources
- Batch updates - Efficient bulk score updates
- Score history - Historical score tracking
Account Relationships
Security Model
Access Control
| Action | Authority |
|---|---|
| Initialize DAO | DAO authority |
| Register member | Member wallet |
| Create proposal | Member wallet (tier-gated) |
| Cast vote | Member wallet |
| Update scores | Authorized oracle updaters |
| Execute proposal | Anyone (after time-lock) |
Flash Loan Protection
The contracts implement multiple flash loan protections:
- Minimum active days - 30-day requirement before participation
- Score snapshots - Recorded at vote time
- Score decay detection - Triggers on sudden drops
- Time-locks - Delays before execution
Constants
pub const REPUTATION_MULTIPLIER_DENOMINATOR: u64 = 50;
pub const MIN_ACTIVE_DAYS: u64 = 30;
pub const TIME_LOCK_PLATINUM: i64 = 24 * 60 * 60; // 24 hours
pub const TIME_LOCK_GOLD: i64 = 48 * 60 * 60; // 48 hours
pub const TIME_LOCK_SILVER: i64 = 72 * 60 * 60; // 72 hours
pub const TIME_LOCK_BRONZE: i64 = 168 * 60 * 60; // 7 days
pub const TIME_LOCK_DEFAULT: i64 = 336 * 60 * 60; // 14 days
pub const SCORE_DECAY_THRESHOLD: u64 = 10;Error Codes
| Code | Error | Description |
|---|---|---|
| 6000 | InsufficientReputationTier | Member tier too low for action |
| 6001 | InsufficientActiveDays | Account not active long enough |
| 6002 | ProposalVotingActive | Voting period still active |
| 6003 | TimeLockNotExpired | Time-lock period not finished |
| 6004 | ScoreManipulation | Score snapshot mismatch |
| 6005 | ScoreDecayDetected | Sudden score drop detected |
| 6006 | InsufficientBadges | Not enough badges for emergency |
| 6007 | DelegationAlreadyActive | Already delegating |
| 6008 | InvalidDelegationTarget | Cannot delegate to self |
| 6009 | QuorumNotReached | Minimum participation not met |
| 6010 | FlashLoanDetected | Potential flash loan attack |
Events
All major actions emit events for indexing:
MemberRegistered { wallet, fairscore, tier }
MemberScoreUpdated { wallet, old_score, new_score, new_tier }
ProposalCreated { proposal, proposer, proposal_type, voting_end, time_lock_expiry }
VoteCast { proposal, voter, vote, voting_power, fairscore }
ProposalFinalized { proposal, state, for_votes, against_votes }
ProposalExecuted { proposal, executed_at }
DelegationCreated { delegator, delegate, efficiency }
DelegationRevoked { delegator }Next Steps
CredDAO Program
Deep dive into the main governance contract.
FairScore Oracle
Learn about the reputation scoring system.