Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Comprehensive Implementation of Bitcoin-Powered DAO Smart Contract #1

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ed42ff7
feat: Add initial implementation of Bitcoin-Powered DAO contract
salako-slide Nov 29, 2024
7bda9a3
feat: Add data maps for members, proposals, votes, and collaborations
salako-slide Nov 29, 2024
30bfb23
feat: Add public functions for membership management
salako-slide Nov 29, 2024
6836bb8
feat: Add public functions for staking and unstaking tokens
salako-slide Nov 29, 2024
5808fbb
feat: Add public functions for proposal management
salako-slide Nov 29, 2024
8b7c1dd
feat: Add public function to execute proposals
salako-slide Nov 29, 2024
3095b0b
feat: Add public function to donate to the treasury
salako-slide Nov 29, 2024
495e7ce
feat: Add public functions for cross-DAO collaboration
salako-slide Nov 29, 2024
95e1631
feat: Add read-only functions for treasury balance and member reputation
salako-slide Nov 29, 2024
8ab10d7
feat: Add read-only functions for proposals, members, and totals
salako-slide Nov 29, 2024
12c488e
feat: Add private functions for member and proposal validation
salako-slide Nov 29, 2024
21898cb
feat: Add private functions for proposal and collaboration ID validation
salako-slide Nov 29, 2024
f267a6b
feat: Add private functions for voting power calculation and reputati…
salako-slide Nov 29, 2024
2b8213a
feat: Add public function to decay inactive members' reputation
salako-slide Nov 29, 2024
f46cba9
feat: Initialize contract state variables
salako-slide Nov 29, 2024
e67ea72
feat: Add README documentation for Bitcoin-Powered DAO Smart Contract
salako-slide Nov 29, 2024
31cdd27
feat: Add README documentation for Bitcoin-Powered DAO Smart Contract
salako-slide Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions Clarinet.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
[project]
name = "decentralized-autonomous-org"
description = ""
name = 'decentralized-autonomous-org'
description = ''
authors = []
telemetry = true
cache_dir = "./.cache"

# [contracts.counter]
# path = "contracts/counter.clar"

cache_dir = './.cache'
requirements = []
[contracts.bitcoin-powered-dao]
path = 'contracts/bitcoin-powered-dao.clar'
clarity_version = 2
epoch = 2.5
[repl.analysis]
passes = ["check_checker"]
check_checker = { trusted_sender = false, trusted_caller = false, callee_filter = false }
passes = ['check_checker']

# Check-checker settings:
# trusted_sender: if true, inputs are trusted after tx_sender has been checked.
# trusted_caller: if true, inputs are trusted after contract-caller has been checked.
# callee_filter: if true, untrusted data may be passed into a private function without a
# warning, if it gets checked inside. This check will also propagate up to the
# caller.
# More informations: https://www.hiro.so/blog/new-safety-checks-in-clarinet
[repl.analysis.check_checker]
strict = false
trusted_sender = false
trusted_caller = false
callee_filter = false
132 changes: 132 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# Bitcoin-Powered DAO Smart Contract

## Overview

This smart contract implements a decentralized autonomous organization (DAO) powered by Bitcoin, providing a robust framework for collaborative governance, treasury management, and cross-DAO interactions.

## Features

### 1. Membership Management

- Join and leave the DAO
- Stake and unstake tokens
- Track member reputation and interactions

### 2. Proposal System

- Create proposals with titles and descriptions
- Vote on proposals with weighted voting power
- Execute or reject proposals based on voting results
- Proposal lifecycle management

### 3. Treasury Management

- Donate tokens to the DAO treasury
- Manage and track treasury balance
- Spend treasury funds through proposal execution

### 4. Reputation System

- Members earn reputation through:
- Creating proposals
- Voting
- Donating to the treasury
- Reputation decays for inactive members

### 5. Cross-DAO Collaboration

- Propose collaborations with other DAOs
- Accept and manage inter-DAO proposals

## Key Components

### Constants

- Error codes for various validation checks
- Contract owner definition

### Data Structures

- `members`: Tracks member information (reputation, stake, last interaction)
- `proposals`: Stores proposal details
- `votes`: Tracks member votes on proposals
- `collaborations`: Manages cross-DAO collaboration proposals

## Functions

### Membership Functions

- `join-dao()`: Allow a user to become a DAO member
- `leave-dao()`: Allow a member to exit the DAO
- `stake-tokens(amount)`: Stake tokens in the DAO
- `unstake-tokens(amount)`: Withdraw staked tokens

### Proposal Functions

- `create-proposal(title, description, amount)`: Create a new proposal
- `vote-on-proposal(proposal-id, vote)`: Vote on an existing proposal
- `execute-proposal(proposal-id)`: Execute or reject a proposal after voting

### Treasury Functions

- `donate-to-treasury(amount)`: Contribute tokens to the DAO treasury
- `get-treasury-balance()`: Retrieve current treasury balance

### Collaboration Functions

- `propose-collaboration(partner-dao, proposal-id)`: Propose a collaboration with another DAO
- `accept-collaboration(collaboration-id)`: Accept a cross-DAO collaboration proposal

### Utility Functions

- `decay-inactive-members()`: Reduce reputation for long-inactive members
- Various read-only functions to query DAO state

## Reputation Mechanism

The contract implements a dynamic reputation system:

- Initial reputation: 1 point when joining
- Gain reputation by:
- Creating a proposal: +1 point
- Voting on a proposal: +1 point
- Donating to treasury: +2 points
- Executing a successful proposal: +5 points for the creator
- Reputation decays by 50% after 30 days of inactivity

## Voting Power Calculation

Voting power is calculated as: `(reputation * 10) + stake`

- Ensures both long-term commitment and financial investment are considered

## Security Considerations

- Role-based access control
- Multiple validation checks
- Prevents double voting
- Protects against unauthorized treasury access

## Contract Initialization

- Starts with zero members, proposals, and treasury balance

## Error Handling

Comprehensive error codes cover scenarios like:

- Unauthorized actions
- Already existing members
- Invalid proposals
- Insufficient funds
- Voting restrictions

## Deployment

- Deployed on the Stacks blockchain
- Requires STX tokens for transactions
- Contract owner has special permissions

## Contribution

Interested in contributing? Please read the contribution guidelines and submit pull requests to improve the DAO's functionality.
Loading