A Solana program for distributing tokens to multiple recipients using merkle tree verification. This program enables efficient and secure token airdrops with advanced features for managing large-scale token distributions across the Solana ecosystem.
Boost-TokenDistributor-Solana/
├── programs/
│ └── token_distributor/
│ ├── Cargo.toml
│ ├── Xargo.toml
│ └── src/
│ ├── constants.rs
│ ├── error.rs
│ ├── event.rs
│ ├── instructions/
│ │ ├── claim.rs
│ │ ├── close_claim_status.rs
│ │ ├── create_distributor.rs
│ │ ├── mod.rs
│ │ ├── set_merkle_root.rs
│ │ ├── set_time.rs
│ │ └── withdraw.rs
│ ├── lib.rs
│ ├── state/
│ │ ├── claim_state.rs
│ │ ├── distributor_state.rs
│ │ ├── mod.rs
│ │ └── nonce_state.rs
│ ├── test/
│ │ ├── mod.rs
│ │ └── test_merkle.rs
│ └── utils/
│ ├── mod.rs
│ ├── token.rs
│ └── verify.rs
├── tests/
│ ├── token_distributor.ts
│ ├── token_distributor_bankrun.ts
│ ├── token_distributor_bankrun_simple.ts
│ ├── token_distributor_litesvm.ts
│ └── utils/
│ └── merkle_tree.ts
├── Anchor.toml
├── Cargo.toml
├── package.json
└── README.md
- programs/token_distributor/: Core Solana program implementation with all instructions and state management
- tests/: Comprehensive test suite including multiple testing frameworks (Bankrun, LiteSVM, and standard Anchor tests)
- Node.js 18+ and npm/yarn
- Anchor Framework v0.31.1+
- Solana CLI
- Basic understanding of Solana and TypeScript
# Install dependencies
yarn install
# Build the program
anchor build
# Run tests
anchor testThe project includes multiple test suites for comprehensive validation:
- Standard Anchor Tests:
tests/token_distributor.ts- Traditional Anchor testing - Bankrun Tests:
tests/token_distributor_bankrun.ts- High-performance testing framework - LiteSVM Tests:
tests/token_distributor_litesvm.ts- Fast simulation testing - Simple Bankrun:
tests/token_distributor_bankrun_simple.ts- Simplified test examples
- create_distributor: Initialize a new token distribution campaign with automatic nonce management
- set_time: Configure distribution start and end times (14-day window, can be modified before distribution starts)
- set_merkle_root: Set merkle root for claim verification
- claim: Allow users to claim tokens with merkle proof verification
- withdraw: Reclaim remaining tokens after distribution ends
- close_claim_status: Close claim status accounts for rent recovery
- Merkle Tree Verification: Secure and efficient claim validation
- Time-Bounded Distributions: Configurable 14-day distribution windows
- Role-Based Access Control: Owner and operator role separation
- Persistent Claim Tracking: Maintains claim status across merkle root updates
- Cross-Program Compatibility: Supports both SPL Token and Token 2022
- Event System: Comprehensive event emission for tracking and analytics
- Distributor PDA: Stores distribution parameters and state
- Token Vault PDA: Holds tokens to be distributed, controlled by distributor
- Claim Status PDAs: Track individual user claim progress
- Owner Nonce PDA: Manages automatic nonce assignment for multiple distributions
- Merkle Tree: Off-chain structure for efficient claim verification
- PDA-based access control with owner/operator role separation
- Merkle proof verification for claim eligibility
- Time-based distribution windows to prevent manipulation
- Overflow protection with checked arithmetic
- CEI (Checks-Effects-Interactions) pattern implementation
- Support for both SPL Token and Token 2022 programs
# Run linting
yarn lint
# Fix linting issues
yarn lint:fixThis project supports multiple testing approaches:
- Standard Anchor Tests: Traditional testing with full blockchain simulation
- Bankrun: High-performance testing with parallel execution
- LiteSVM: Fast simulation for rapid development cycles
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
- Make your changes
- Add or update tests as needed
- Ensure all tests pass
- Submit a Pull Request with a clear description of your changes
This project is licensed under the MIT License - see the LICENSE file for details.