1

I'm making multiple swap tokens soft, so i work with a lot of different SPL tokens. The issue i ran in to is transfering all of this tokens in one or few transactions. Let's say i create one transaction and user choose to transfer 40 SPL tokens in to SOL, when i add 40 instructions to one transaction it shows me that Transaction cant be bigger than 1232. Of course i know that's a limit but how do i split that one transaction in to few smaller in that case? It would be nice for my bussiness to also sort that transactions to send most valuable tokens first (i use jupiter api to fetch price). How do i do that? For sorting i implemented algorithm that based on tokens amount, which is ofc not what i want. I use JS.

Thanks

1 Answer 1

1

There are a few things you could try:

  • If you're using a lot of the same tokens every time, you could use VersionedTransactions and Lookup Tables to increase the number of accounts you can send.
  • If you use Jupiter API to get their prices and then sort by value, you can create a function that loops through the tokens in order and builds a transaction out of the first X, easiest by trial and error to determine what X is, and then build Y transactions.
  • Send the transactions in parallel, if they're not dependent on each other or finishing in order. You can build all the transactions first and then send them out at once using a Promise.all or similar depending on where you're writing this.

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.