create_merkle_tree

Function create_merkle_tree 

Source
pub fn create_merkle_tree(participants: Vec<DailyParticipantData>) -> MerkleTree
Expand description

Create a merkle tree from participant data.

This is a convenience function that creates a merkle tree from a vector of participant data. It’s the primary entry point for off-chain processors.

§Parameters

  • participants: Vector of daily participant data

§Returns

  • MerkleTree instance with root and proof generation capabilities

§Panics

  • If participants vector is empty

§Example

use miracle_api::{sdk, prelude::{DailyParticipantData, MerkleTree}};

// Off-chain processor aggregates daily payments
let participants = vec![
    DailyParticipantData::new([1u8; 32], 1723680000, 1723766400, [1u8; 8], [2u8; 8], 5, 0),
    DailyParticipantData::new([2u8; 32], 1723680000, 1723766400, [3u8; 8], [4u8; 8], 10, 1),
];

// Create merkle tree
let merkle_tree = sdk::create_merkle_tree(participants);
println!("Merkle root: {:?}", merkle_tree.root());