Decentralized prediction markets with immutable time-locked commitments on Stellar Soroban
๐ Frontend: https://arpit-jindal-01.github.io/TimeLock-Predictions/
Contract ID: CC2OBONLPDUPDMWJ34E77F2YKECLCWC5XS26EZG2KVV5OAS3LW4ZP2MD
View on Stellar Expert: Contract Explorer
TimeLock Predictions is a blockchain-based prediction market where users stake tokens on future outcomes, but with a unique twist: answers are permanently locked in time capsules until the resolution date.
Unlike traditional prediction markets where users can change their minds, TimeLock creates immutable commitments. Users can't chicken out, can't change positions, and can't manipulate outcomes.
- โ Immutable Commitments - Once staked, answers are locked on-chain forever
- โ Time-Locked - Enforced by Stellar smart contracts
- โ Proportional Payouts - Stake more, win more
- โ Anti-Spam - Creation fee + initial stake requirement
- โ Transparent Revenue - 5% platform fee, 70% creation fee to treasury
- โ Fully Tested - 10/10 comprehensive unit tests passing
- โ Rising Logo - Smooth animated entrance
- โ Floating Particles - Continuous background animation
- โ Dual Wallet Connection - Freighter + Manual public key
- โ Live XLM Balance - Real-time from Stellar network
- โ Instant Deductions - Visual balance updates (150 XLM per prediction)
- โ Analytics Dashboard - 4 Chart.js visualizations
- โ User Profile - History, stats, achievements
- โ Mobile Optimized - Responsive design for all devices
- โ Notification System - Browser + in-app notifications
- โ Social Sharing - Twitter, Telegram, WhatsApp
| Component | Technology |
|---|---|
| Blockchain | Stellar Soroban (Testnet) |
| Smart Contract | Rust |
| Frontend | HTML5, CSS3, JavaScript |
| Wallet | Freighter API |
| SDK | Stellar SDK v11.3.0 |
| Charts | Chart.js v4.4.0 |
| CLI Tool | Stellar CLI v23.1.4 |
| Token | XLM (Stellar Lumens) |
| Network | Testnet |
| RPC URL | https://soroban-testnet.stellar.org |
| Horizon URL | https://horizon-testnet.stellar.org |
| Deployment | GitHub Pages |
// Initialize contract
initialize(admin: Address)
// Create new prediction
create_prediction(
creator: Address,
question: String,
unlock_time: u64,
initial_choice: bool,
token: Address
) -> u64
// Stake on prediction
stake(
prediction_id: u64,
user: Address,
choice: bool,
amount: i128,
token: Address
)
// Resolve prediction (admin only)
resolve(
admin: Address,
prediction_id: u64,
winner_choice: bool
)
// Claim winnings
claim(
prediction_id: u64,
user: Address,
token: Address
) -> i128get_prediction(prediction_id: u64) -> Prediction
get_stake(prediction_id: u64, user: Address) -> Option<Stake>
get_prediction_count() -> u64
get_treasury() -> i128withdraw_treasury(admin: Address, amount: i128, token: Address)User โ Pays 50 XLM creation fee + 100 XLM initial stake
โ Chooses YES or NO
โ Sets unlock time (must be 1+ hour in future)
โ Question stored on-chain
Users โ Choose YES or NO
โ Lock minimum 100 XLM
โ Can't change answer once locked
โ Tokens go into prize pool
โณ Prediction sealed until unlock time
โ Cannot withdraw
โ Cannot change answer
โ Cannot resolve early
After unlock time โ Admin picks winner (YES/NO)
โ Smart contract calculates payouts
โ 5% platform fee deducted
โ 95% distributed to winners proportionally
Winners โ Call claim() function
โ Receive proportional share
โ Formula: (your_stake / winning_pool) ร prize_pool
- 70% (35 XLM) โ Platform treasury
- 30% (15 XLM) โ Burned (deflationary)
- Deducted on resolution
- Goes to platform treasury
- Industry standard rate
- Prevents spam staking
- Ensures meaningful participation
- Required for prediction creators
Visit: https://arpit-jindal-01.github.io/TimeLock-Predictions/
Option A: Freighter Wallet (Recommended)
- Install Freighter extension
- Create/import wallet
- Switch to Stellar Testnet
- Click "Connect Freighter Wallet"
- Approve connection
Option B: Manual Public Key
- Click "Enter Public Key" button
- Paste your Stellar public key (G...)
- Click "Connect"
- Sign transactions with Freighter
curl "https://friendbot.stellar.org?addr=YOUR_PUBLIC_KEY"- Check your XLM balance (top right)
- Fill in prediction question
- Set unlock date (future)
- Choose your answer (Yes/No)
- Click "Create Prediction"
- Watch balance deduct 150 XLM instantly
- Analytics: View charts and statistics
- Profile: Check your prediction history
- Social: Share predictions on Twitter/Telegram
- Mobile: Works seamlessly on phones
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Install Stellar CLI
cargo install --locked soroban-cli --features opt
# Verify installation
stellar --versioncd contract
stellar contract buildcargo teststellar keys generate admin --network testnet
stellar keys address admincurl "https://friendbot.stellar.org?addr=$(stellar keys address admin)"stellar contract deploy \
--wasm target/wasm32v1-none/release/timelock_predictions.wasm \
--source admin \
--network testnetstellar contract invoke \
--id <CONTRACT_ID> \
--source admin \
--network testnet \
-- initialize \
--admin $(stellar keys address admin)running 10 tests
test test::test_initialize ... ok
test test::test_double_initialize - should panic ... ok
test test::test_create_prediction ... ok
test test::test_create_prediction_invalid_time - should panic ... ok
test test::test_create_prediction_short_question - should panic ... ok
test test::test_stake ... ok
test test::test_double_stake - should panic ... ok
test test::test_resolve_and_claim ... ok
test test::test_resolve_too_early - should panic ... ok
test test::test_claim_loser - should panic ... ok
test result: ok. 10 passed; 0 failed
- โ Contract initialization
- โ Prediction creation (valid & invalid)
- โ Staking mechanism
- โ Double-staking prevention
- โ Time lock enforcement
- โ Resolution logic
- โ Proportional payout calculation
- โ Winner/loser validation
- โ Edge cases & error handling
CREATION_FEE: 50 XLM (50_0000000 stroops)
MIN_STAKE: 100 XLM (100_0000000 stroops)
ONE_HOUR: 3600 seconds
PLATFORM_FEE: 5% of prize pool
TREASURY_SPLIT: 70% to treasury, 30% burnedstellar contract invoke \
--id <CONTRACT_ID> \
--source creator \
--network testnet \
-- create_prediction \
--creator $(stellar keys address creator) \
--question "Will Bitcoin hit $100k by 2025?" \
--unlock_time 1735689600 \
--initial_choice true \
--token <NATIVE_TOKEN_ADDRESS>stellar contract invoke \
--id <CONTRACT_ID> \
--source user \
--network testnet \
-- stake \
--prediction_id 1 \
--user $(stellar keys address user) \
--choice false \
--amount 2000000000 \
--token <NATIVE_TOKEN_ADDRESS>stellar contract invoke \
--id <CONTRACT_ID> \
--source admin \
--network testnet \
-- resolve \
--admin $(stellar keys address admin) \
--prediction_id 1 \
--winner_choice truestellar contract invoke \
--id <CONTRACT_ID> \
--source winner \
--network testnet \
-- claim \
--prediction_id 1 \
--user $(stellar keys address winner) \
--token <NATIVE_TOKEN_ADDRESS>- โ
Authorization Checks -
require_auth()on all user actions - โ Admin Validation - Only admin can resolve predictions
- โ Time Lock Enforcement - Cannot resolve before unlock_time
- โ Double-Stake Prevention - One stake per user per prediction
- โ Input Validation - Question length, minimum stakes, time limits
- โ Overflow Protection - Safe integer math
- โ Reentrancy Safe - State updates before external calls
- Smart contract with 10 functions
- Comprehensive test suite (10/10 passing)
- Deployed to testnet
- Zero warnings build
- Animated UI with rising logo
- Freighter wallet integration
- Manual public key login
- Live XLM balance display
- Instant balance deductions
- Analytics dashboard
- User profile page
- Mobile optimization
- Notification system
- Social sharing
- GitHub Pages deployment
- Oracle integration (Chainlink) for automatic resolution
- Community voting for subjective questions
- Group predictions (friends compete)
- Reputation system
- NFT achievement badges
- Streak tracking (5-win, 10-win bonuses)
- Advanced leaderboard
- Mainnet deployment
- Custom domain
- Manual Resolution: Currently requires admin to resolve predictions (oracle integration coming in Phase 2)
- Testnet Only: Not audited for mainnet deployment yet
- Single Token: Only supports native XLM token currently
- No Cancellation: Predictions cannot be cancelled once created (by design)
MIT License - See LICENSE file for details
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Write tests for new features
- Ensure all tests pass
- Submit a pull request
- Issues: GitHub Issues
- Stellar Discord: Stellar Developers
- Documentation: Stellar Docs
This is experimental software. Use at your own risk. Not audited for production use. Test thoroughly before deploying to mainnet.
- ๐ Stellar Soroban
- ๐ฆ Rust
- โก Stellar CLI
- ๐งช Thoroughly Tested
Made with ๐ฅ for the Stellar ecosystem