BitFutures is a decentralized prediction market smart contract built on the Stacks blockchain that allows users to make predictions about Bitcoin price movements. Users can stake STX tokens on their predictions and earn rewards for correct predictions.
- Create prediction markets with customizable parameters
- Make "up" or "down" predictions with STX stakes
- Automated market resolution and reward distribution
- Configurable minimum stake amounts and fee structure
- Oracle-based price feed integration
- Fair and transparent reward calculation
make-prediction
: Place a prediction with a stake on a marketclaim-winnings
: Claim rewards for correct predictionsget-market
: View details of a specific marketget-user-prediction
: Check prediction details for a specific userget-contract-balance
: View the current contract balance
create-market
: Create a new prediction marketresolve-market
: Resolve a market with final price dataset-oracle-address
: Update the oracle addressset-minimum-stake
: Modify the minimum stake requirementset-fee-percentage
: Adjust the platform fee percentagewithdraw-fees
: Withdraw accumulated platform fees
- Market Creation: Admin creates a market with start price and timeframe
- Active Period: Users make predictions by staking STX
- Resolution: Oracle provides final price and market is resolved
- Claims: Winners can claim their rewards
- Minimum stake: 1 STX (1,000,000 microSTX)
- Default fee: 2%
- Error codes: 100-106 for various error conditions
;; Market Structure
{
start-price: uint,
end-price: uint,
total-up-stake: uint,
total-down-stake: uint,
start-block: uint,
end-block: uint,
resolved: bool
}
;; Prediction Structure
{
prediction: (string-ascii 4),
stake: uint,
claimed: bool
}
;; Stake 5 STX on an upward price movement
(contract-call? .bitfutures make-prediction u1 "up" u5000000)
;; Claim winnings from market #1
(contract-call? .bitfutures claim-winnings u1)
- Oracle-dependent for price feeds
- Time-locked predictions based on block height
- Owner-only administrative functions
- Built-in checks for:
- Minimum stake amounts
- Valid prediction values
- Market timing
- Double-claiming prevention
- Balance verification
- Deploy the contract to the Stacks blockchain
- Initialize oracle address
- Configure minimum stake and fee parameters
- Create first market
To modify or extend the contract:
- Clone the repository
- Make changes to the Clarity smart contract
- Test thoroughly using Clarinet
- Deploy updated contract