coinbase / coinbase/coinbase-sdk-nodejs

mass-payout.js (not batching?)

Open
#416 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
123
Forks
94
PR merge metrics
No merged PRs in 30d

Description

https://github.com/coinbase/coinbase-sdk-nodejs/blob/524a5724fc89770d992f40032d9da4a1978ca70b/quickstart-template/mass-payout.js#L79

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.