Skip to content

mass-payout.js (not batching?) #416

Description

@jtan-sl

Question, in function sendMassPayout... the await transfer.wait() call, wouldn't this make the code not batch and wait for each transfer to complete?

Should we skip this transfer.wait(); but store the "pending transfers" in an array and then check their status later?

something like this:

const transfers = [];

// STEP 1: Queue all transfers (sequentially to enable batching)
for (const address of recipients) {
  const transfer = await wallet.createTransfer({
            amount: transferAmount,
            assetId: assetId,
            destination: address,
  });

  transfers.push({ address, transfer });
  console.log(`Queued transfer to ${address}`);
}

// STEP 2: Only after all are queued, check for status
for (const { address, transfer } of transfers) {
  await transfer.wait(); // Now we can wait without blocking the next transfer
  const status = transfer.getStatus();

  if (status === 'complete') {
    console.log(`Completed for ${address}`);
  } else {
    console.error(`Failed for ${address}`);
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions