0

I have a dApp that creates a single batch transaction in Javascript and sends it (through Taquito) to beacons wallets (Kukai, Temple, etc.) and it is working flawlessly. However, after around 1500 operations inside the batch, it begins taking too long to the beacon wallet to receive the batch.

It's a huge JSON with elements like this:

{
    kind: OpKind.TRANSACTION,
    to: 'tz1...9CjNjBHju',
    amount: 2000000,
    mutez: true
}

It works, but seems to the user that the browser has hung.

Is there a workaround to optimize this?

Edits: code added->

for (var k=0;k<this.totalDelegators;k++)
{
   .
   .
   .
   let element = {
                    kind: OpKind.TRANSACTION, 
                    to: delegator.address, 
                    amount: value, 
                    mutez: true  
                 }; 

   this.myBatchArray.push(element);

}

const batch = this.Tezos.wallet.batch(myBatchArray);
const batchOp = await batch.send();
console.log('Batch operation hash : ', batchOp.hash);
await batchOp.confirmation(1);

What takes long time to process is batch.send(), not when is mounted in the loop (which is instantaneous).

2
  • 1
    Please add the javascript code where you create the batch transaction and send it. Without the code it is not possible to give further help. With the code maybe we can help and give suggestions how to optimize it.
    – user9011
    Apr 10, 2023 at 22:26
  • Will add the code above,in the question. Apr 10, 2023 at 22:34

1 Answer 1

0

If you can, please share how you are forming the batch operation.

Based on how Taquito batch operations work. It should create a single POST to the chain with all the operations collected.

However, I haven't seemed to be able to recreate your type of operation as I get rejected with an oversized_operation error the largest batch operation I can create is with ~500 transactions. It fails before 1000 transactions in the batch due to the "max_operation_data_length": 32768 protocol constant.

The time may be due to operations being iterated rather than sending the batch. For my test, the longest part was generating all of the functions.

I hope this helps shed some clarity! I can help with a bit more context. I don't believe there is much difference in awaiting operation confirmation, and it could be because of how the operations are generated or added to the batch.

4
  • Thanks for your kind response. I have a data structure, a Javascript array, which is being used as a way of mounting the batch transaction. The processing of this array is not the problem. It's filled fast (less than a second) with elements like shown above in my question. Then I send the entire array to the wallet using Taquito methods: const batch = this.Tezos.wallet.batch(myBatchArray); const batchOp = await batch.send(); console.log('Batch operation hash : ', batchOp.hash); await batchOp.confirmation(1); Apr 10, 2023 at 22:15
  • Note that it actually works. Even with 2,500 transactions inside the batch. However, it takes minutes to send from my dApp to the beacon wallet (which receives it gracefully). If I prune it to, say, 1,000 transactions, the difference is big. Much, much faster. Nevertheless, above 1,500 starts to slow down. Apr 10, 2023 at 22:22
  • I do not loop and send one transaction at each iteration. Rather, I mount my entire operation in memory and after all done, I send the entire array to the beacon wallet. Apr 10, 2023 at 22:25
  • Also, I can assure you that Taquito is not iterating and sending individual transactions to the wallet, because the wallet shows a single operation with many transactions inside. Apr 10, 2023 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.