Bitcoin Native DAO Smart Contract Implementation - #1
Open
esthercodez1 wants to merge 19 commits into
Open
esthercodez1 wants to merge 19 commits into
esthercodez1 wants to merge 19 commits into
Conversation
- Define contract owner constant - Add error constants for various contract conditions: - Owner-only actions - Insufficient balance - Proposal not found - Already voted - Proposal expired - Invalid amount - Not a stakeholder - Proposal not active - Invalid quorum - Proposal not expired
- Define minimum stake (1 BTC in sats) - Initialize proposal count to 0 - Set quorum percentage to 51% - Set voting period to approximately 1 day in Bitcoin blocks
- Define proposals map with the following fields: - title: ASCII string (max 100 characters) - description: ASCII string (max 500 characters) - proposer: principal - amount: uint - recipient: principal - start-block: uint - end-block: uint - yes-votes: uint - no-votes: uint - status: ASCII string (max 20 characters) - executed: bool
- Define stakes map with the following fields: - amount: uint - lock-until: uint
- Define votes map with the following fields: - proposal-id: uint - voter: principal - voted: bool - vote: bool
- get-proposal: Retrieve proposal details by proposal ID - get-stake: Retrieve stake details by staker principal - get-vote: Retrieve vote details by proposal ID and voter principal - calculate-voting-power: Calculate voting power based on staker's amount
- is-proposal-active: Determine if a proposal is active based on block height and status
- stake: Allows users to stake a specified amount of tokens - Transfers tokens to the contract - Updates the staker's amount and lock period - Ensures the amount is above the minimum stake
- unstake: Allows users to unstake a specified amount of tokens - Transfers tokens back to the user - Updates the staker's amount and lock period - Ensures the amount is available and the lock period has expired
- create-proposal: Allows users to create a new proposal - Requires a title, description, amount, and recipient - Checks if the proposer has the minimum stake - Sets proposal details including start and end blocks, and initializes votes and status - Increments the proposal count
- vote: Allows users to vote on a proposal - Checks if the proposal is active and the user has not voted before - Records the user's vote - Updates the proposal's yes-votes or no-votes based on the user's stake
- execute-proposal: Allows users to execute a proposal - Checks if the proposal is not already executed and has expired - Verifies if the proposal meets the quorum requirements - Transfers the proposal amount to the recipient if approved - Updates the proposal status to executed or rejected
- update-minimum-stake: Allows the contract owner to update the minimum stake amount - Ensures the caller is the contract owner - Sets the new minimum stake value
- update-quorum-percentage: Allows the contract owner to update the quorum percentage - Ensures the caller is the contract owner - Validates the new percentage is between 1 and 100 - Sets the new quorum percentage value
- update-voting-period: Allows the contract owner to update the voting period - Ensures the caller is the contract owner - Sets the new voting period value
- Renamed private is-valid-recipient function to is-valid-recipient-private
- Resolved runtime error: NameAlreadyUsed("is-valid-recipient")
- Improved code clarity and removed function duplication
…main branch This commit introduces a comprehensive README for the Bitcoin Native DAO smart contract. The README includes the following sections: - Overview of the DAO and its purpose - Key functionalities such as staking, proposal creation, voting, and treasury management - Detailed explanation of contract components, including constants, data variables, and main functions - Security measures implemented in the contract - Usage examples to guide users in interacting with the smart contract - Deployment requirements and initial configuration guidelines - Limitations, considerations, and recommended improvements for future development - Contribution guidelines for the community This README serves as a foundational guide for developers, users, and contributors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces a comprehensive implementation of a Bitcoin Native DAO (Decentralized Autonomous Organization) smart contract on the Stacks blockchain. The contract provides a robust framework for decentralized governance, enabling Bitcoin holders to participate in collective decision-making through staking, proposal creation, and voting mechanisms.
Key Features Implemented
Staking Mechanism
Governance Functionality
Treasury Management
Notable Improvements
Changes Detailed
Contract Components
Core Functions
stake(): Token staking with lock periodsunstake(): Token withdrawal mechanismcreate-proposal(): Proposal submission with validationvote(): Stake-weighted votingexecute-proposal(): Proposal execution with quorum checksAdministrative Functions
update-minimum-stake()update-quorum-percentage()update-voting-period()set-whitelisted-recipient()Testing Considerations
Potential Future Enhancements
Documentation
A comprehensive README has been added, providing:
Checklist
Reviewer Guidance
Please review:
Approval Status
Pending comprehensive review and testing.