Skip to content

Baskarayelu/predictify-contracts

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Predictify Contracts

Platform: Stellar Soroban
Language: Rust
License: MIT

๐Ÿ“– About

Predictify Contracts is a comprehensive prediction market platform built on Stellar's Soroban smart contract platform. The system enables users to create and participate in prediction markets with hybrid resolution mechanisms that combine real-time oracle data (from Pyth Network and Reflector oracles) with community voting. This platform is designed for developers, traders, and organizations looking to build decentralized prediction markets with institutional-grade oracle integration, dispute resolution, and governance features.

The project is ideal for developers building on Stellar, smart contract auditors, and teams creating prediction market applications that require reliable price feeds, community governance, and robust dispute resolution mechanisms.


๐Ÿ“‹ Table of Contents

  1. Quick Start
  2. Project Structure
  3. Setup Instructions
  4. Development
  5. Testing
  6. Deployment
  7. Documentation
  8. Contributing

๐Ÿš€ Quick Start

# Clone the repository
git clone <repository-url>
cd predictify-contracts

# Install dependencies (Rust and Soroban CLI)
# See Setup Instructions below

# Build contracts
cd contracts/predictify-hybrid
make build

# Run tests
make test

๐Ÿ“ Project Structure

predictify-contracts/
โ”œโ”€โ”€ contracts/
โ”‚   โ”œโ”€โ”€ hello-world/          # Example contract for reference
โ”‚   โ””โ”€โ”€ predictify-hybrid/    # Main prediction market contract
โ”‚       โ”œโ”€โ”€ src/              # Contract source code
โ”‚       โ””โ”€โ”€ Makefile          # Build and test commands
โ”œโ”€โ”€ docs/                     # Comprehensive documentation
โ”‚   โ”œโ”€โ”€ api/                  # API reference
โ”‚   โ”œโ”€โ”€ contracts/            # Contract-specific docs
โ”‚   โ”œโ”€โ”€ gas/                  # Gas optimization guides
โ”‚   โ”œโ”€โ”€ operations/           # Deployment and operations
โ”‚   โ””โ”€โ”€ security/             # Security documentation
โ”œโ”€โ”€ Cargo.toml                # Workspace configuration
โ””โ”€โ”€ README.md                 # This file

Key Components:

  • predictify-hybrid: Main prediction market contract with oracle integration, voting, disputes, and governance
  • hello-world: Reference contract demonstrating basic Soroban patterns

๐Ÿ› ๏ธ Setup Instructions

Requirements

  • Rust (latest stable version)
  • Soroban CLI (version 20.0.0 or later)
  • Stellar Account (for deployment and testing)
  • Git (for cloning the repository)

Installation

1. Install Rust

# Install Rust using rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Verify installation
rustc --version
cargo --version

2. Install Soroban CLI

# Install Soroban CLI
cargo install --locked --version 20.0.0 soroban-cli

# Verify installation
soroban --version

3. Install Stellar Contract Tools

# Install Stellar contract build tools
cargo install --locked stellar-cli

# Verify installation
stellar --version

Environment Setup

Configure Stellar Networks

# Add testnet (recommended for development)
soroban config network add testnet \
  --rpc-url https://soroban-testnet.stellar.org:443 \
  --network-passphrase "Test SDF Network ; September 2015"

# Add futurenet (for testing new features)
soroban config network add futurenet \
  --rpc-url https://rpc-futurenet.stellar.org:443 \
  --network-passphrase "Test SDF Future Network ; October 2022"

# Add mainnet (for production deployment)
soroban config network add mainnet \
  --rpc-url https://rpc.mainnet.stellar.org:443 \
  --network-passphrase "Public Global Stellar Network ; September 2015"

Set Default Network

# Use testnet for development
soroban config network use testnet

Environment Variables

Create a .env file in the project root (or .env.testnet for testnet):

# .env.testnet
NETWORK=testnet
DEPLOYER_SECRET_KEY="SB..."  # Your deployer account secret key
ADMIN_ADDRESS="GB..."        # Admin account address
ORACLE_CONTRACT="..."        # Oracle contract address (optional for testing)

โš ๏ธ Security Note: Never commit .env files to version control. Add them to .gitignore.

Build the Project

# From project root
cd contracts/predictify-hybrid

# Build the contract
make build

# Or use cargo directly
cargo build --target wasm32-unknown-unknown --release

The compiled WASM file will be at:

target/wasm32-unknown-unknown/release/predictify_hybrid.wasm

๐Ÿงช Testing

Run All Tests

# From contract directory
cd contracts/predictify-hybrid
make test

# Or use cargo directly
cargo test

Run Specific Test Suites

# Unit tests only
cargo test --lib

# Integration tests
cargo test --test integration_test

# Property-based tests
cargo test --test property_based_tests

Test on Testnet

# Deploy to testnet for integration testing
soroban contract deploy \
  --wasm target/wasm32-unknown-unknown/release/predictify_hybrid.wasm \
  --network testnet \
  --source $DEPLOYER_SECRET_KEY

# Initialize the contract
soroban contract invoke \
  --id <contract_id> \
  --fn initialize \
  --network testnet \
  --source $DEPLOYER_SECRET_KEY \
  --arg admin=$ADMIN_ADDRESS

๐Ÿš€ Deployment

Deploy to Testnet (Recommended First Step)

# Ensure you're on testnet
soroban config network use testnet

# Deploy contract
soroban contract deploy \
  --wasm target/wasm32-unknown-unknown/release/predictify_hybrid.wasm \
  --network testnet \
  --source $DEPLOYER_SECRET_KEY

# Save the contract ID from the output
CONTRACT_ID="<contract_id_from_output>"

# Initialize contract
soroban contract invoke \
  --id $CONTRACT_ID \
  --fn initialize \
  --network testnet \
  --source $DEPLOYER_SECRET_KEY \
  --arg admin=$ADMIN_ADDRESS

Deploy to Mainnet

โš ๏ธ Production Deployment Checklist:

  • All tests passing
  • Security audit completed
  • Testnet deployment verified
  • Admin keys secured (preferably multisig)
  • Oracle contracts configured
  • Monitoring setup ready
# Switch to mainnet
soroban config network use mainnet

# Deploy contract
soroban contract deploy \
  --wasm target/wasm32-unknown-unknown/release/predictify_hybrid.wasm \
  --network mainnet \
  --source $DEPLOYER_SECRET_KEY

# Initialize contract
soroban contract invoke \
  --id $CONTRACT_ID \
  --fn initialize \
  --network mainnet \
  --source $DEPLOYER_SECRET_KEY \
  --arg admin=$ADMIN_ADDRESS

# Record contract ID securely
echo "Mainnet Contract ID: $CONTRACT_ID" >> deployment.log

Verify Deployment

# Inspect deployed contract
soroban contract inspect \
  --id $CONTRACT_ID \
  --network $NETWORK

๐Ÿ“š Documentation

Quick Links

Documentation Categories

๐Ÿ”’ Security

โ›ฝ Gas Optimization

๐Ÿ› ๏ธ Operations

๐Ÿ“‹ Contracts


๐Ÿค Contributing

We welcome contributions! Here's how to get started:

Development Workflow

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/your-feature-name
  3. Make your changes
    • Follow Rust formatting: cargo fmt --all
    • Ensure tests pass: make test
    • Update documentation as needed
  4. Commit your changes
    git commit -m "Add: description of your changes"
  5. Push and create a Pull Request

Code Standards

  • Formatting: Use cargo fmt --all before committing
  • Testing: All new features must include tests
  • Documentation: Update relevant docs for new features
  • Security: Review security implications of changes

Contribution Guidelines

  • Issues: Use GitHub issues for bug reports and feature requests
  • Pull Requests: Include description of changes and test results
  • Code Review: All PRs require review before merging
  • Testing: Ensure all tests pass and add tests for new features

Getting Help

  • Documentation: Check the docs directory
  • Issues: Search existing issues or create a new one
  • Discussions: Use GitHub Discussions for questions

๐Ÿ”ฎ Oracle Setup

The Predictify Hybrid contract supports multiple oracle providers for price feeds:

Supported Oracles

  • Pyth Network: Institutional-grade price feeds with high-frequency updates (400ms)
  • Reflector Oracle: Stellar-native oracle with proven track record
  • Custom Oracles: Extensible architecture for additional providers

Oracle Configuration

See the Contract README for detailed oracle setup instructions and integration examples.


๐Ÿ” Development

Code Formatting

# Format all code
cargo fmt --all

# Or from contract directory
cd contracts/predictify-hybrid
make fmt

Running Tests

# Run all tests
make test

# Run with output
cargo test -- --nocapture

# Run specific test
cargo test test_name

Project Structure

  • contracts/predictify-hybrid/src/: Main contract source code
    • lib.rs: Contract entry point and main implementation
    • markets.rs: Market creation and management
    • oracles.rs: Oracle integration (Pyth, Reflector)
    • voting.rs: Community voting system
    • disputes.rs: Dispute resolution mechanism
    • governance.rs: Governance and admin functions
    • types.rs: Core data structures
    • errors.rs: Error definitions

Adding New Features

  1. Create feature branch
  2. Implement feature with tests
  3. Update documentation
  4. Run full test suite
  5. Submit PR with description

๐Ÿ“Š Monitoring

Tools

  • Stellar Expert: Blockchain explorer
  • Soroban CLI: Contract inspection and interaction
  • Custom Scripts: Monitor transactions and events

Key Metrics

  • Oracle submission frequency and reliability
  • Market creation and resolution rates
  • Dispute activations and resolution times
  • Gas costs and optimization opportunities

๐Ÿ” Security

Security Best Practices

  • Review Security Documentation before deployment
  • Complete security audit checklist
  • Use hardware wallets for admin keys
  • Implement multisig for critical operations
  • Monitor for suspicious activity

Reporting Security Issues

โš ๏ธ Do not open public issues for security vulnerabilities.

Please report security issues privately to the maintainers. See Security Best Practices for details.


๐Ÿ“ License

This project is open source and available under the MIT License.


๐Ÿ”— Additional Resources


๐Ÿ’ฌ Support


Last updated: 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%