-
Hi there, I have a situation where I have an address with 2,000 SUI coin objects. I was wondering how I can merge all these coin objects and transfer them to another address. Is it possible to do this through a single transaction, or do I need to make multiple transactions to merge them first and then transfer them at the end? I'm interested in a solution using the TypeScript SDK. Any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I have come up with a solution, but I'm not sure if it is optimal:
this line |
Beta Was this translation helpful? Give feedback.
-
There are limits you might hit. For gas coins the limit is 256 so you'd have to do this 10 times, for objects inputs its 1024. So I would create a generic function that accepts a list of up to 1000 coins and merges them normally, like take the first coin from the array and merge the rest into them and then just send the coin to the same address. Then I'd call this function twice but with "await" so make sure you get a response from the first one to call the second. Lastly after all 2000 objects are merged into 2 objects, assuming you want to empty this address I'd create a PTB that transfers tx.gas to the new address. When called like that available coins will be merged (since 2 < 256). |
Beta Was this translation helpful? Give feedback.
I have come up with a solution, but I'm not sure if it is optimal: