To initialize an instance of the ZebecBulkClient class, you need to provide a signer or provider and optionally specify contract addresses for BulkTransfer and Core. Here's an example of how to initialize the class:
import { ethers } from "ethers";
import { ZebecBulkClient } from "@zebec-protocol/zebec-bnb-sdk";
// Initialize with a signer (e.g., MetaMask)
const signer = new ethers.Wallet("your-private-key");
const bulkClient = new ZebecBulkClient(signer);
initBlulkInstantTransfer method initializes a bulk stream with a bulk tree root, start times, and other parameters.
getBulkInstantTransferRoot function is designed to calculate and retrieve the Merkle tree root for a bulk instant transfer. This function is used to create a Merkle tree structure that represents a set of instant token transfers that will occur simultaneously.
updateBulkInstantTransferRoot function is used to update an existing bulk instant transfer by recalculating the Merkle tree root based on new transfer data.
updateBulkTransfer method updates a bulk transfer with new information such as a merkle root and start times.
This method allows a user to withdraw funds from a bulk instant transfer using merkle proofs.
Note: The purpose of the getLatestBulkCount function is to determine the number of bulk transfers that a user has created within the Zebec protocol. Bulk transfers are collections of individual token streams, and each bulk transfer has a unique index or identifier.
The calculateLatestBulkBytes function in the ZebecBulkClient class is used to calculate the byte representation of the latest bulk transfer associated with a specific user's address. This function allows you to obtain the byte representation of the most recent bulk transfer.
Get Bulk Transfer Root
const bulkBytes = "0xabcdef123456..."; // Replace with the actual bulk transfer identifier
// Retrieve the Merkle root of the specified bulk transfer
const bulkTransferRoot = await bulkClient.getBulkTransferRoot(bulkTransferBytes);
console.log(`Merkle Root of Bulk Transfer: ${bulkTransferRoot}`)
The getBulkTransferRoot function is used to retrieve the Merkle root associated with a specific bulk transfer.
Verify Bulk Transfer
// Verify the bulk instant transfer
const verified = await bulkClient.verifyBulkInstantTransfer(
index,
amount,
tokenAddress,
sender,
receiver,
proofs
);
if (verified) {
console.log("Bulk Instant Transfer is valid and verified.");
} else {
console.log("Bulk Instant Transfer is not valid.");
}
The purpose of the verifyBulkInstantTransfer function is to perform verification checks on a bulk instant transfer to ensure that it matches the expected properties and has not been manipulated or tampered with.