batch_claim_date_range

Function batch_claim_date_range 

Source
pub fn batch_claim_date_range(
    signer: Pubkey,
    beneficiary: Pubkey,
    start_date: i64,
    end_date: i64,
    participant_type: u8,
    max_batch_size: u8,
    merkle_proofs: Vec<Vec<u8>>,
    social_data: Option<Vec<Option<SocialClaimData>>>,
) -> Result<Instruction, MiracleError>
Expand description

Builds a batch claim instruction for a date range.

This function converts the date range to epochs and creates a vector claim. It provides a user-friendly interface for claiming rewards across multiple days.

§Parameters

  • signer: The wallet signing the transaction
  • beneficiary: The wallet receiving the rewards
  • start_date: Start date as Unix timestamp
  • end_date: End date as Unix timestamp (inclusive)
  • participant_type: 0 = customer, 1 = merchant
  • max_batch_size: Maximum epochs per batch (1-10)
  • merkle_proofs: Vector of Merkle proof data for each epoch

§Returns

  • Instruction for batch claiming rewards across the date range

§Note

  • The date range is converted to epochs using date_range_to_epochs
  • Each epoch requires its own Merkle proof in the merkle_proofs vector
  • The number of proofs must match the number of epochs in the range
  • If the date range is invalid or too large, returns an error

§Example

use miracle_api::sdk;
use solana_program::pubkey::Pubkey;

let signer = Pubkey::new_unique();
let beneficiary = Pubkey::new_unique();
let merkle_proofs = vec![vec![1, 2, 3], vec![4, 5, 6]]; // Example proofs

let instruction = sdk::batch_claim_date_range(
    signer,
    beneficiary,
    1756792800, // Sept 1, 2025 00:00:00 UTC
    1756879199, // Sept 1, 2025 23:59:59 UTC
    0, // customer
    10, // max batch size
    merkle_proofs, // proofs for epoch 0
    None, // social_data (no social claims)
);

Batch claim instruction for date range - uses correct 8-account structure