Batch Transfer SPL Token that has Token transfer extension enabled

Batch Transfer SPL Token that has Token transfer extension enabled

Manage alerts

Loading saved threads...

Sol Addict · External communityPost link
External question — Solana Stack Exchange Author: Sol Addict Original post: https://solana.stackexchange.com/questions/13411 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Is it even possible to batch transfer an SPL token that has a Token transfer(token fee) extension enabled? I would Like to create a program which takes the destination wallet from a JSON file and iterates through each address to create or check the associated token for the mint token and then transfer the token with the right fee amount and batch them all into one transaction. I have a working typescript to "transferCheckWithFee" that sends a single transaction to send the token to one destination wallet, const sourceAccount = await createAssociatedTokenAccountIdempotent(connection, payer, mint, owner.publicKey, {}, TOKEN_2022_PROGRAM_ID); const destinationAccount = await createAssociatedTokenAccountIdempotent(connection, payer, mint, destinationOwner.publicKey, {}, TOKEN_2022_PROGRAM_ID); const transferSig = await transferCheckedWithFee( connection, payer, sourceAccount, mint, destinationAccount, owner, transferAmount, decimals, fee, [], undefined, TOKEN_2022_PROGRAM_ID ); but not sure how to batch for multiple destination wallets in a single transaction. Can you guys help develop such a typescript program? Thanks
Quote
Report
Jon C · External communityPost link
External answer — Solana Stack Exchange Author: Jon C Original post: https://solana.stackexchange.com/a/13521 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. If you want to do multiple transfers in one transaction, you'll need to create the transaction by hand and add the instructions one by one. Here's an untested example: const transaction = new Transaction().add( createTransferCheckedWithFeeInstruction( sourceAccount, mint, destinationAccount, owner.publicKey, transferAmount, decimals, fee, ), createTransferCheckedWithFeeInstruction( sourceAccount, mint, nextDestinationAccount, owner.publicKey, transferAmount, decimals, fee, ), // next instruction // next instruction ); await sendAndConfirmTransaction(connection, transaction, [payer, owner]); You may run into the transaction size restriction of 1232 bytes if you add a lot of instructions to a transaction, but you'll get a very loud error if that happens.
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Solana Stack Exchange Author: Sol Addict Source score (net votes, not local likes): 1 Original post: https://solana.stackexchange.com/questions/13411 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Is it even possible to batch transfer an SPL token that has a Token transfer(token fee) extension enabled? I would Like to create a program which takes the destination wallet from a JSON file and iterates through each address to create or check the associated token for the mint token and then transfer the token with the right fee amount and batch them all into one transaction. I have a working typescript to "transferCheckWithFee" that sends a single transaction to send the token to one destination wallet, const sourceAccount = await createAssociatedTokenAccountIdempotent(connection, payer, mint, owner.publicKey, {}, TOKEN_2022_PROGRAM_ID); const destinationAccount = await createAssociatedTokenAccountIdempotent(connection, payer, mint, destinationOwner.publicKey, {}, TOKEN_2022_PROGRAM_ID); const transferSig = await transferCheckedWithFee( connection, payer, sourceAccount, mint, destinationAccount, owner, transferAmount, decimals, fee, [], undefined, TOKEN_2022_PROGRAM_ID ); but not sure how to batch for multiple destination wallets in a single transaction. Can you guys help develop such a typescript program? Thanks

Cancel quote

Checking account access…