Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation:
This change introduces a
Batch-Transfer
action to the token blueprint. This functionality is essential for scenarios requiring multiple token transfers from a single sender, such as airdrops, payroll, or reward distributions. Performing these transfers individually is inefficient, incurs higher message overhead, and lacks atomicity guarantees across the entire set of transfers. TheBatch-Transfer
action addresses these issues by allowing multiple transfers to be processed within a single message, ensuring atomicity and reducing memory usage on the token process.Implementation Details:
Action = "Batch-Transfer"
.msg.Data
field, where each line represents a transfer in the formatrecipient_address,quantity
.msg.From
) balance is checked against this total quantity.Batch-Debit-Notice
is always sent back to the sender (viamsg.reply
). This notice includes the total number of transfers (Count
), the total quantity transferred (Total
), and crucially, aBatch-Transfer-Init-Id
tag containing themsg.Id
of the originalBatch-Transfer
message for easy traceability.Transfer
action, individualCredit-Notice
messages are sent to each recipient only if the initiatingBatch-Transfer
message does not include theCast = true
tag. IfCast
is present, these individual notifications are suppressed (recommended behavior).X-
on the originalBatch-Transfer
message are forwarded to both theBatch-Debit-Notice
and any individualCredit-Notice
messages sent.Caveats:
recipient,quantity
).