A decentralized autonomous organization (DAO) for managing a Bitcoin/STX treasury through community governance on the Stacks blockchain.
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.
- 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
- Add/remove members with assigned voting power
- Track total membership and individual voting rights
- Owner-controlled membership administration
- Deposit STX tokens to the DAO treasury
- View real-time treasury balance
- Propose fund transfers with descriptions
- Execute approved proposals automatically
- Authorization checks on all sensitive operations
- Double-voting prevention
- Proposal expiration enforcement
- Execution replay attack prevention
- Emergency withdrawal capability (owner only)
| 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 |
add-member(new-member, voting-power)- Add new DAO member (owner only)remove-member(member)- Remove existing member (owner only)
deposit(amount)- Deposit STX to treasury (anyone)emergency-withdraw(amount, recipient)- Emergency fund recovery (owner only)
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)
update-quorum(new-quorum)- Change quorum percentage (owner only)update-voting-period(new-period)- Change voting duration (owner only)
| 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 |
;; Contract deployer is automatically added as first member
;; Add additional members
(contract-call? .dao add-member 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM u1);; Deposit 1000 STX
(contract-call? .dao deposit u1000000000);; Propose sending 100 STX
(contract-call? .dao create-proposal
'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
u100000000
"Fund community development project");; Vote yes on proposal #1
(contract-call? .dao vote u1 true);; After voting period ends and proposal passes
(contract-call? .dao execute-proposal u1)- Language: Clarity
- Blockchain: Stacks
- Token: STX
- Lines of Code: 284
- Default Quorum: 51%
- Default Voting Period: 1440 blocks (~10 days)
- Owner Privileges: Contract owner has emergency withdrawal rights
- Voting Period: Proposals cannot be executed until voting period expires
- Quorum Enforcement: Proposals must meet minimum participation
- Single Vote: Each member can only vote once per proposal
- Balance Checks: All transfers verify sufficient treasury funds