Bulk Instant Transfer
Initializing the Class
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);Initialize Bulk Instant
const bulkStreamName = "YourBulkStreamName";
const now = Math.floor(Date.now() / 1000);
const amounts = ["1", "2", "3"];
const tokenAddress = "0xTokenAddress";
const receivers = [receiver1.address, receiver2.address, receiver3.address];
const startTimes = [BigNumber.from(now + 100)]; // An array of start times. Length must be equal to recurring Frequency
const recurringFrequency = 1;
const overrides = {}; // Optional overrides
const bulkInstantTree = await bulkClient.getBulkInstantTransferRoot(
tokenAddress,
amounts,
receivers
);
const txnReceipt = await bulkClient.initBlulkInstantTransfer(
bulkStreamName,
bulkInstantTree.root,
startTimes,
recurringFrequency
);
console.log(txnReceipt);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.
Update Bulk Transfer
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.
Withdraw Bulk Instant Transfer By Receiver
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.
Cancel Bulk Instant Transfer
This method cancels a bulk instant transfer.
Calculate Latest Bulk Bytes
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
The getBulkTransferRoot function is used to retrieve the Merkle root associated with a specific bulk transfer.
Verify Bulk Transfer
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.
Last updated