Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

SportX Challenge

A Solana-based smart contract for managing sports challenges and rewards distribution. This program allows users to participate in weekly sports challenges by staking SOL tokens and earning rewards upon successful completion.

Features

  • Weekly challenge cycles with three states: Registration, Active, and Completed
  • NFT-based participation verification (users must hold specific NFTs to participate)
  • SOL token staking for challenge participation
  • Automated reward distribution to successful participants
  • Admin controls for challenge management
  • Batch processing support for activity completion verification

Prerequisites

  • Rust 1.70.0 or later
  • Solana CLI tools
  • Node.js 20.x or later
  • Anchor Framework 0.29.0
  • A Solana wallet with SOL tokens for testing

Installation

  1. Clone the repository:
git clone <repository-url>
cd sportx_challenge
  1. Install dependencies:
npm install
  1. Build the program:
anchor build

Program Structure

Main Components

  • StateAccount: Stores global challenge state

    • Authority (admin) address
    • Registration fee amount
    • NFT collection address
    • Activity status
    • Participant statistics
  • ParticipantAccount: Stores individual participant data

    • User address
    • Completion status
    • Registration timestamp

Key Instructions

  1. initialize: Sets up the challenge program

    • Sets registration fee
    • Configures NFT collection
    • Initializes state account
  2. register: User registration

    • Verifies NFT ownership
    • Collects registration fee
    • Creates participant account
  3. upload_data: Records user completion

    • Admin-only function
    • Marks user as completed
    • Updates completion statistics
  4. settle: Distributes rewards

    • Calculates rewards per successful participant
    • Transfers SOL tokens
    • Resets challenge state

Testing

Run the test suite:

anchor test

The test suite includes:

  • Program initialization
  • User registration
  • Activity status management
  • Completion verification
  • Reward distribution

Deployment

  1. Configure your Solana cluster in Anchor.toml:
[provider]
cluster = "devnet"  # or "mainnet-beta"
wallet = "~/.config/solana/id.json"
  1. Deploy the program:
anchor deploy

Security Considerations

  • All admin functions require authority signature
  • NFT ownership verification for participation
  • Secure PDA-based account management
  • Proper access control for all instructions
  • Safe arithmetic operations using checked math

License

MIT License

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages