-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Bitcoin-backed Universal Basic Income Protocol #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
carlton-source
wants to merge
22
commits into
main
Choose a base branch
from
feature/smart-contract
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- Defined `contract-owner` as `tx-sender` - Added error constants for various error scenarios: - `err-owner-only` for owner-only actions - `err-already-registered` for already registered users - `err-not-registered` for unregistered users - `err-ineligible` for ineligible users - `err-cooldown-active` for active cooldown periods - `err-insufficient-funds` for insufficient funds - `err-invalid-amount` for invalid amounts - `err-unauthorized` for unauthorized actions
- Added `treasury-balance` to track the contract's treasury balance - Added `total-participants` to track the number of registered participants - Added `distribution-amount` to define the amount of UBI distribution (1 STX = 1,000,000 micro-STX)
- Added `distribution-interval` to define the interval between distributions (~1 day in blocks) - Added `last-distribution-height` to track the block height of the last distribution - Added `minimum-balance` to set the minimum required treasury balance - Added `paused` to indicate whether the contract is paused
- Added `participants` map to store participant details including registration status, claim history, verification status, join height, and claims count
- Added `voter-records` map to track voting records by proposal ID and voter principal
- Added `is-contract-owner` private function to verify if the transaction sender is the contract owner
- Added `is-eligible` private function to verify if a participant is eligible for UBI distribution based on verification status, claim interval, and treasury balance
- Added `update-participant-record` private function to update a participant's claim history, including last claim height, total claimed amount, and claims count
- Added `register` public function to allow participants to register for UBI - Ensures participants are not already registered - Initializes participant record with default values - Increments the total number of participants
- Added `claim-ubi` public function to allow eligible participants to claim UBI - Checks if the contract is not paused - Verifies participant eligibility - Ensures sufficient treasury balance - Processes the claim by transferring UBI amount and updating participant record
- Added `contribute` public function to allow users to contribute STX to the contract's treasury - Ensures the contribution amount is greater than zero - Transfers the contribution amount to the contract - Updates the treasury balance with the contributed amount
- Added `submit-proposal` public function to allow registered participants to submit governance proposals - Generates a unique proposal ID - Ensures the proposer is a registered participant - Stores the proposal details including proposer, proposal type, proposed value, votes, status, and expiry height
- Added `vote` public function to allow participants to vote on governance proposals - Ensures the voter is a registered participant - Checks if the voter has not already voted on the proposal - Records the vote and updates the proposal's vote counts
- Added `pause` public function to allow the contract owner to pause the contract - Ensures only the contract owner can execute this function - Sets the `paused` variable to true
- Added `unpause` public function to allow the contract owner to unpause the contract - Ensures only the contract owner can execute this function - Sets the `paused` variable to false
- Added `get-participant-info` read-only function to retrieve information about a participant - Returns the participant's record from the `participants` map
- Added `get-treasury-balance` read-only function to retrieve the current balance of the contract's treasury
- Added `get-proposal` read-only function to retrieve details of a governance proposal by its ID
- Added `get-distribution-info` read-only function to retrieve details about UBI distribution including amount, interval, last distribution height, and minimum balance
- Added comprehensive description of the Bitcoin-backed Universal Basic Income Protocol - Included features such as participant management, UBI distribution, governance system, and safety features - Provided technical details including constants and error codes - Detailed usage instructions for participants, governance, and administrators - Listed governance parameters and query functions - Added security considerations and notes for proper usage - Included guidelines for contributing to the protocol - Specified the MIT License for the protocol
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.
Overview
This PR implements a comprehensive Universal Basic Income (UBI) protocol backed by Bitcoin, featuring participant management, automated distributions, governance mechanisms, and security controls.
Key Changes
Core Infrastructure
Data Structures
Core Functions
Private Functions
is-contract-owner: Contract ownership verificationis-eligible: Participant eligibility checkingupdate-participant-record: Participant record managementPublic Functions
Participant Management
register: User registration systemverify-participant: Verification processclaim-ubi: Distribution claimingcontribute: Treasury contributionsGovernance
submit-proposal: Proposal submissionvote: Voting mechanismpause/unpause: Emergency controlsQuery Functions
get-participant-info: Participant data retrievalget-treasury-balance: Treasury balance checkingget-proposal: Proposal informationget-distribution-info: Distribution parametersDocumentation
Testing
Security Considerations
Deployment Checklist
Dependencies
Documentation Updates
Notes for Reviewers
Please pay special attention to: