Smart Contract Deep Dive
Technical documentation for ArcaLana's Solana smart contracts, covering all instructions, account structures, security measures, and deployment details.
Smart Contract Overview
ArcaLana's smart contract is built using the Anchor framework on Solana, implementing a complete on-chain gaming platform with transparent scoring, seasonal competitions, and automated reward distribution.
📋 Contract Details
- Program ID:
6yoNCf8kg4uoeoz13MvuomPQiFzZ1wev95fQLiaRzAU6 - Network: Solana Devnet
- Framework: Anchor v0.30.1
- Language: Rust
- Status: Active & Tested
Architecture Principles
- Decentralized: No single admin controls rewards or seasons
- Transparent: All operations verifiable on-chain
- Efficient: Optimized for low transaction costs
- Secure: Comprehensive access controls and validation
- Extensible: Modular design for future game additions
Core Instructions
The smart contract implements 10 core instructions that handle all platform functionality from initialization to reward distribution.
🔧 Administrative Instructions
initialize
Sets up the global platform state with initial configuration and admin authority.
create_season
Creates a new gaming season with specified duration and reward vault.
fund_season
Adds SOL to a season's reward vault, increasing total prize pool.
end_season
Finalizes a season, calculates winners, and enables reward claims.
🎮 Player Instructions
submit_score
Records a player's game score with entry fee payment and leaderboard update.
claim_reward
Allows winners to claim their calculated rewards after season completion.
📊 Query Instructions
get_leaderboard
Retrieves current leaderboard rankings for a specific season.
get_player_stats
Fetches individual player statistics across all seasons and games.
calculate_rewards
Previews reward distribution before season ends for transparency.
get_season_info
Returns comprehensive information about any season's status and metrics.
Account Types
The smart contract manages four primary account types, each with specific roles in the platform ecosystem.
🌐 PlatformState
PDA Seed: ["platform"]
Global platform configuration and administrative controls.
Key Fields:
admin- Platform administrator pubkeytreasury_wallet- Platform fee destinationadmin_fee_percentage- Platform fee (30%)total_seasons- Season counteris_paused- Emergency pause state
🏆 Season
PDA Seed: ["season", season_id]
Individual season data including timing, participants, and vault management.
Key Fields:
season_id- Unique season identifierstart_time / end_time- Season durationvault_balance- Total prize poolparticipant_count- Number of playersis_ended- Season completion statuswinners- Array of determined winners
🎮 PlayerScore
PDA Seed: ["score", season_id, player_pubkey, game_type]
Individual score records linking players to their game performance.
Key Fields:
player- Player wallet pubkeyseason_id- Associated seasongame_type- Game variant (Snake/Space/Block)score- Raw game scorenormalized_score- Cross-game comparable scoretimestamp- Submission time
👤 PlayerProfile
PDA Seed: ["player", player_pubkey]
Persistent player statistics and historical performance data.
Key Fields:
player- Player wallet pubkeytotal_games_played- Lifetime game counttotal_seasons_participated- Season countbest_scores- Personal records by gametotal_rewards_earned- Lifetime earningsfirst_play_date- Account creation
Security Architecture
ArcaLana implements multiple layers of security to protect player funds, ensure fair gameplay, and prevent unauthorized access.
Access Control Matrix
| Instruction | Required Authority | Additional Checks |
|---|---|---|
| initialize | System Admin | One-time only, sets up initial state |
| create_season | Platform Admin | Valid time range, unique season ID |
| fund_season | Any User | Season exists and not ended |
| submit_score | Player (Self) | Season active, valid entry fee |
| end_season | Platform Admin | Season ended, winners calculated |
| claim_reward | Winner (Self) | Season ended, not already claimed |
Vault Security
🔐 Program Derived Addresses (PDAs)
All vaults use PDAs ensuring only the smart contract can authorize transfers.
🛡️ Multi-Signature Requirements
Critical operations require multiple validation steps and signature verification.
⏰ Time-Based Validation
Season timing enforced on-chain preventing premature or late submissions.
💰 Economic Security
Entry fees prevent spam, vault balances tracked with precision arithmetic.
Anti-Cheating Measures
- Score Normalization: Cross-game scoring prevents exploitation of easier games
- Entry Fee Gates: Economic barrier to spam submissions
- Time Validation: Scores only accepted during active seasons
- Duplicate Prevention: One score per player per game per session
- Admin Oversight: Manual winner verification for lucky draws
Deployment Information
Current deployment status and technical specifications for the ArcaLana smart contract.
Program ID: 6yoNCf8kg4uoeoz13MvuomPQiFzZ1wev95fQLiaRzAU6
🚀 Current Deployment
- Network: Solana Devnet
- Deploy Date: January 2024
- Version: v2.0.0
- Status: Active & Operational
⚡ Performance Metrics
- Transaction Cost: ~0.005 SOL average
- Confirmation Time: 1-2 seconds
- Account Size: Optimized for minimal rent
- Concurrent Players: Unlimited theoretical capacity
- Uptime: 99.9% (blockchain dependent)
🔧 Technical Stack
- Rust Version: 1.75.0
- Anchor Version: 0.30.1
- Solana CLI: 1.18.0
- Node.js: 18.x LTS
- Dependencies: Minimal external crates
Mainnet Migration Plan
Security Audit
Third-party security audit completion and vulnerability assessment
Community Testing
Extended beta testing period with community feedback integration
Mainnet Deployment
Production deployment with full documentation and support resources
Testing & Verification
Comprehensive testing ensures contract reliability, security, and performance across all use cases and edge conditions.
Test Coverage
🧪 Unit Tests
- Individual instruction validation
- Account state transitions
- Mathematical calculations
- Error handling scenarios
- Edge case boundary testing
🔗 Integration Tests
- End-to-end season workflows
- Multi-player interactions
- Cross-instruction dependencies
- Real-world usage patterns
- Performance under load
🛡️ Security Tests
- Unauthorized access attempts
- Reentrancy attack prevention
- Integer overflow/underflow
- PDA derivation security
- Economic exploit prevention
✅ Verification Checklist
- All 10 instructions tested with valid inputs
- Error cases handled gracefully with descriptive messages
- PDA derivations mathematically verified
- Reward calculations tested with multiple scenarios
- Season lifecycle tested from creation to completion
- Multi-player concurrent access validated
- Economic model verified with real transaction flows
- Security vulnerabilities assessed and mitigated