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.
- 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
- 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
- Clone the repository:
git clone <repository-url>
cd sportx_challenge- Install dependencies:
npm install- Build the program:
anchor build-
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
-
initialize: Sets up the challenge program- Sets registration fee
- Configures NFT collection
- Initializes state account
-
register: User registration- Verifies NFT ownership
- Collects registration fee
- Creates participant account
-
upload_data: Records user completion- Admin-only function
- Marks user as completed
- Updates completion statistics
-
settle: Distributes rewards- Calculates rewards per successful participant
- Transfers SOL tokens
- Resets challenge state
Run the test suite:
anchor testThe test suite includes:
- Program initialization
- User registration
- Activity status management
- Completion verification
- Reward distribution
- Configure your Solana cluster in
Anchor.toml:
[provider]
cluster = "devnet" # or "mainnet-beta"
wallet = "~/.config/solana/id.json"- Deploy the program:
anchor deploy- 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
MIT License
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request