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}`);
}
}
coinbase-sdk-nodejs/quickstart-template/mass-payout.js
Line 79 in 524a572
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: