Skip to content

Conversation

@carlton-source
Copy link
Owner

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

  • Established contract ownership and error handling framework
  • Implemented treasury management system with balance tracking
  • Added participant registration and verification system
  • Created distribution management with configurable intervals

Data Structures

  • Added data maps for participant management and voting records
  • Implemented state variables for protocol configuration
  • Created governance proposal tracking system

Core Functions

Private Functions

  • is-contract-owner: Contract ownership verification
  • is-eligible: Participant eligibility checking
  • update-participant-record: Participant record management

Public Functions

  • Participant Management

    • register: User registration system
    • verify-participant: Verification process
    • claim-ubi: Distribution claiming
    • contribute: Treasury contributions
  • Governance

    • submit-proposal: Proposal submission
    • vote: Voting mechanism
    • pause/unpause: Emergency controls

Query Functions

  • get-participant-info: Participant data retrieval
  • get-treasury-balance: Treasury balance checking
  • get-proposal: Proposal information
  • get-distribution-info: Distribution parameters

Documentation

  • Added comprehensive README
  • Included usage instructions and examples
  • Documented security considerations
  • Added contribution guidelines

Testing

  • Add unit tests for all public functions
  • Add integration tests for governance workflow
  • Test emergency pause functionality
  • Verify participant management system
  • Test distribution mechanisms

Security Considerations

  1. Implemented balance checks and overflow protection
  2. Added owner-only access controls
  3. Created participant verification system
  4. Added emergency pause functionality
  5. Implemented cooldown periods

Deployment Checklist

  • Verify all constants are correctly configured
  • Ensure error codes are properly documented
  • Check governance parameters
  • Verify minimum balance requirements
  • Test pause/unpause functionality

Dependencies

  • Clarity smart contract language
  • Bitcoin integration capabilities
  • Stacks blockchain infrastructure

Documentation Updates

  • Added new README
  • Included function documentation
  • Added usage examples
  • Updated contribution guidelines

Notes for Reviewers

Please pay special attention to:

  1. Security mechanisms in distribution functions
  2. Governance implementation
  3. Error handling
  4. Treasury management logic
  5. Participant verification flow

- 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants