RE: Is Bulk Receiving Possible?

Dear Team,

Is there a way to bulk receive objects that are transferred to an object?

E.g, take an object named donation_box (whether owned or shared).

Let’s say donation_box has over 1 million donations (social donations only)

Let’s say that a DAO owns the donation_box object and there are over a million objects to be received.

If the DAO processes new donations each weekend, then how might this be handled?

If we try to use PTBs:

const data = await client.getOwnedObjects({ owner: "0x..." });
for (let i = 0; i < data['data'].length; i++) {
    trx.moveCall({
        target: `${process.env.PACKAGE_ID}::xxx::anyfunction`,
        arguments: [trx.object("0xparent"), trx.object(0xreceiving)]
    });
}
const { objectChanges, balanceChanges } = await client.signAndExecuteTransactionBlock({
    signer: keypair, 
    transactionBlock: trx, 
    options: {
        showBalanceChanges: true,
        showEvents: true,
    }
});

Since PTBs can perform up to 1,024 unique operations in a single execution, therefore the transaction will fail?

Is there an alternative way of handling this use case when using Transfer to Object?

@amnn @shb Hello team, waiting for your input on this.

Just some practical bounding:

First thing to keep in mind is the max transaction bytes limit as well. Currently this is "max_tx_size_bytes": 131072,

So you’ll never get 1 million and will need to chunk it up.

Other than that, function args would need to support vector<Receiving<T>> which you can check pretty quickly in your editor and/or testing the module.

Hi @bipin_bhandari, Frank has given you some great pointers here so I’ll mostly reinforce them:

Various limits on transactions will prevent you from processing 1 million objects in a single transaction, there are multiple limits that could contribute to that (number of input objects, number of commands, number of dynamic object loads, transaction size, etc) and it is difficult to know which one you will hit first without experimentation, but you will certainly hit one and need to chunk work up. Generally doing work on the order of 1000 objects is quite doable per transaction.

We do support handling vector<Receiving<T>> as a function parameter, but it is not supported as a transaction input, so to make a call to such a function, you would need to:

  • Create a PTB with many receiving inputs.
  • Call the MakeMoveVec transaction command to create the vector from those inputs.
  • Call the function passing the result of the MakeMoveVec

This could allow you to process more donations per transaction because you avoid hitting the limit on transaction commands and therefore probably also on overall transaction size.