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}`);
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions