Skip to content

BitFutures: Decentralized Bitcoin Price Prediction Market Implementation#1

Open
samuel-dafeta wants to merge 6 commits into
mainfrom
feature/bitcoin-price-prediction-market
Open

BitFutures: Decentralized Bitcoin Price Prediction Market Implementation#1
samuel-dafeta wants to merge 6 commits into
mainfrom
feature/bitcoin-price-prediction-market

Conversation

@samuel-dafeta

Copy link
Copy Markdown
Owner

Overview

This PR implements a complete decentralized prediction market smart contract for Bitcoin price movements on the Stacks blockchain. The implementation includes core functionality for market creation, user predictions, market resolution, and reward distribution.

Changes

  1. Constants and Error Codes

    • Added administrative constants
    • Implemented comprehensive error handling system
  2. State Management

    • Implemented platform configuration variables
    • Created data structures for markets and predictions
  3. Core Functions

    • Market creation and management
    • Prediction placement system
    • Market resolution mechanism
    • Winnings distribution logic
  4. Administrative Controls

    • Oracle management
    • Fee configuration
    • Stake requirements
    • Fee withdrawal system
  5. Documentation

    • Added detailed README
    • Included function documentation
    • Added integration guidelines

Security Considerations

  • Implemented owner-only access controls
  • Added balance verification
  • Included double-claim prevention
  • Added parameter validation
  • Enabled safe value unwrapping

Deployment Notes

  • Default configuration:
    • Minimum stake: 1 STX
    • Platform fee: 2%
    • Configurable oracle address

Checklist

  • Code follows Clarity best practices
  • Documentation is complete and accurate
  • Security measures are implemented
  • Error handling is comprehensive
  • Configuration is flexible and secure

- Define administrative constants including contract owner and owner-only error.
- Add error codes for various conditions such as not found, invalid prediction, market closed, already claimed, insufficient balance, and invalid parameter.
- Define platform configuration variables including oracle address, minimum stake, fee percentage, and market counter.
- Add data maps for market data structure and user predictions tracking.
… claiming

- Implement `create-market` to initialize a new prediction market.
- Implement `make-prediction` to allow users to place stakes on market outcomes.
- Implement `resolve-market` to finalize market outcomes based on oracle data.
- Implement `claim-winnings` to distribute winnings to users based on their predictions.
- Implement `get-market` to return details of a specific market.
- Implement `get-user-prediction` to return details of a user's prediction in a specific market.
- Implement `get-contract-balance` to return the contract's STX balance.
- Implement `set-oracle-address` to update the oracle address.
- Implement `set-minimum-stake` to update the minimum stake requirement.
- Implement `set-fee-percentage` to update the platform fee percentage.
- Implement `withdraw-fees` to allow the contract owner to withdraw accumulated fees.
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.

1 participant