I want to send SUI coins from a wallet to huge number of addresses in one function call.
I have an array of length > 1,000 :
const transfers = [
{ to: '0xRecipientAddress1', amount: 1000000 },
{ to: '0xRecipientAddress2', amount: 2000000 },
..... 1400 more
];
Note: Amount is in MIST
And this is the code i wrote using @mysten/sui documentation, If thistransfers
array is the passed to this function, will this signAndExecuteTransaction
complete all the transaction in once or it has any limit to number of addresses to send at a time.
// multiTransfer.js
import { Transaction } from '@mysten/sui/transactions';
import { keypair, client } from './wallet.js';
export async function sendBatchSUI(transfers) {
const tx = new Transaction();
const amounts = transfers.map(t => t.amount);
const coins = tx.splitCoins(tx.gas, amounts);
transfers.forEach((t, index) => {
tx.transferObjects([coins[index]], t.to);
});
const result = await client.signAndExecuteTransaction({
transaction: tx,
signer: keypair,
requestType: 'WaitForLocalExecution',
options: {
showEffects: true,
},
});
return result;
}
Also for a detailed context, the client
is a sui wallet that will be used for My App backend to make transactions on transfering sui coins to users