Skip to content

This is a DAO smart contract built on the Stacks blockchain that enables communities to collectively manage a shared STX treasury through democratic governance. It provides a trustless, transparent framework where members can propose expenditures, vote on proposals, and execute approved transactions without requiring centralized control.

Notifications You must be signed in to change notification settings

laraakanbi/Bitcoin-Treasury-DAO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Bitcoin Treasury DAO Smart Contract

A decentralized autonomous organization (DAO) for managing a Bitcoin/STX treasury through community governance on the Stacks blockchain.

Overview

This smart contract enables communities to collectively manage a treasury where members can propose spending, vote on proposals, and execute approved transactions. The system uses weighted voting and quorum-based decision making to ensure democratic governance.

Features

πŸ›οΈ Governance System

  • Weighted Voting: Each member has customizable voting power
  • Quorum Requirements: Proposals must meet minimum participation thresholds (default 51%)
  • Time-Limited Voting: Configurable voting periods (default 1440 blocks ~10 days)
  • Proposal Lifecycle: Create β†’ Vote β†’ Execute workflow

πŸ‘₯ Membership Management

  • Add/remove members with assigned voting power
  • Track total membership and individual voting rights
  • Owner-controlled membership administration

πŸ’° Treasury Operations

  • Deposit STX tokens to the DAO treasury
  • View real-time treasury balance
  • Propose fund transfers with descriptions
  • Execute approved proposals automatically

πŸ”’ Security Features

  • Authorization checks on all sensitive operations
  • Double-voting prevention
  • Proposal expiration enforcement
  • Execution replay attack prevention
  • Emergency withdrawal capability (owner only)

Contract Functions

Read-Only Functions

Function Description
get-proposal Retrieve proposal details by ID
get-member-status Check if an address is a member
get-voting-power Get voting power for a member
has-voted Check if member voted on a proposal
get-treasury-balance View current treasury balance
get-quorum Get current quorum percentage
is-proposal-passed Check if proposal met passing criteria

Public Functions

Membership

  • add-member(new-member, voting-power) - Add new DAO member (owner only)
  • remove-member(member) - Remove existing member (owner only)

Treasury

  • deposit(amount) - Deposit STX to treasury (anyone)
  • emergency-withdraw(amount, recipient) - Emergency fund recovery (owner only)

Proposals

  • create-proposal(recipient, amount, description) - Create new spending proposal (members only)
  • vote(proposal-id, support) - Vote yes/no on proposal (members only)
  • execute-proposal(proposal-id) - Execute passed proposal after voting ends (members only)

Configuration

  • update-quorum(new-quorum) - Change quorum percentage (owner only)
  • update-voting-period(new-period) - Change voting duration (owner only)

Error Codes

Code Error Description
u100 ERR_UNAUTHORIZED Caller lacks permission
u101 ERR_INSUFFICIENT_BALANCE Treasury has insufficient funds
u102 ERR_PROPOSAL_NOT_FOUND Invalid proposal ID
u103 ERR_ALREADY_VOTED Member already voted on proposal
u104 ERR_PROPOSAL_EXPIRED Voting period ended/not ended
u105 ERR_PROPOSAL_NOT_PASSED Proposal didn't meet requirements
u106 ERR_ALREADY_EXECUTED Proposal already executed
u107 ERR_INVALID_AMOUNT Amount must be greater than 0
u108 ERR_MEMBER_EXISTS Member already exists
u109 ERR_NOT_MEMBER Address is not a member
u110 ERR_INVALID_QUORUM Quorum must be 1-100

Usage Example

1. Initialize DAO

;; Contract deployer is automatically added as first member
;; Add additional members
(contract-call? .dao add-member 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM u1)

2. Fund Treasury

;; Deposit 1000 STX
(contract-call? .dao deposit u1000000000)

3. Create Proposal

;; Propose sending 100 STX
(contract-call? .dao create-proposal 
  'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM 
  u100000000 
  "Fund community development project")

4. Vote on Proposal

;; Vote yes on proposal #1
(contract-call? .dao vote u1 true)

5. Execute Proposal

;; After voting period ends and proposal passes
(contract-call? .dao execute-proposal u1)

Technical Details

  • Language: Clarity
  • Blockchain: Stacks
  • Token: STX
  • Lines of Code: 284
  • Default Quorum: 51%
  • Default Voting Period: 1440 blocks (~10 days)

Security Considerations

  1. Owner Privileges: Contract owner has emergency withdrawal rights
  2. Voting Period: Proposals cannot be executed until voting period expires
  3. Quorum Enforcement: Proposals must meet minimum participation
  4. Single Vote: Each member can only vote once per proposal
  5. Balance Checks: All transfers verify sufficient treasury funds

About

This is a DAO smart contract built on the Stacks blockchain that enables communities to collectively manage a shared STX treasury through democratic governance. It provides a trustless, transparent framework where members can propose expenditures, vote on proposals, and execute approved transactions without requiring centralized control.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published