A program to distribute SPL tokens via uploading a Merkle root.
Based on jito airdrop Merkle distributor and optimized with rent-free PDAs.
User ClaimStatus accounts are compressed accounts, to reduce cost for the claim process:
| Account type | Cost per claim | 100k claims |
|---|---|---|
| PDA | ~0.002 SOL | ~200 SOL |
| Compressed PDA | ~0.00005 SOL | ~5 SOL |
- solana cli
- spl-token-cli
cargo install spl-token-cli - light cli
npm i -g @lightprotocol/zk-compression-cli
cargo build-sbf && cargo build -p jito-scriptscargo test-sbflight test-validator --sbf-program mERKcfxMC5SqJn4Ld4BUris3WKZZ1ojjWJ3A3J5CKxv ./target/deploy/merkle_distributor.soMINT=$(spl-token create-token | grep "Address:" | awk '{print $2}')
echo "Mint: $MINT"echo "pubkey,amount_unlocked,amount_locked,category
$(solana address),1000,500,Staker" > test_airdrop.csv./target/debug/cli --mint $MINT --keypair-path ~/.config/solana/id.json --rpc-url http://localhost:8899 \
create-merkle-tree --csv-path ./test_airdrop.csv --merkle-tree-path ./merkle_tree.jsonCLAWBACK=$(spl-token create-account $MINT | grep "Creating account" | awk '{print $3}')
echo "Clawback: $CLAWBACK"Timestamps must satisfy: clawback_start >= end_vesting + 86400 (1 day minimum)
START_TS=$(($(date +%s) + 10))
END_TS=$(($(date +%s) + 60))
CLAWBACK_TS=$((END_TS + 86400 + 60))
./target/debug/cli --mint $MINT --keypair-path ~/.config/solana/id.json --rpc-url http://localhost:8899 \
new-distributor \
--clawback-receiver-token-account $CLAWBACK \
--start-vesting-ts $START_TS \
--end-vesting-ts $END_TS \
--clawback-start-ts $CLAWBACK_TS \
--merkle-tree-path ./merkle_tree.jsonThe previous step prints the token vault address and the mint command.
# Use the command printed by new-distributor, e.g.:
spl-token mint $MINT 1500000000000 <TOKEN_VAULT>./target/debug/cli --mint $MINT --keypair-path ~/.config/solana/id.json --rpc-url http://localhost:8899 \
--photon-url http://localhost:8784 claim --merkle-tree-path ./merkle_tree.jsonThis is a proof of concept implementation, not audited and not ready for production use.