The list of token accounts to select from.
The token amount to be transferred.
OptionalmaxInputs: number = 4The maximum number of accounts to select. Default: 4.
const accounts = [
{ parsed: { amount: new BN(100) }, compressedAccount: { lamports: new BN(10) } },
{ parsed: { amount: new BN(50) }, compressedAccount: { lamports: new BN(5) } },
{ parsed: { amount: new BN(25) }, compressedAccount: { lamports: new BN(2) } },
];
const transferAmount = new BN(75);
const maxInputs = 2;
const [selectedAccounts, total, totalLamports, maxPossibleAmount] =
selectSmartCompressedTokenAccountsForTransfer(accounts, transferAmount, maxInputs);
console.log(selectedAccounts.length); // 2
console.log(total.toString()); // '150'
console.log(totalLamports!.toString()); // '15'
console.log(maxPossibleAmount.toString()); // '150'
Selects compressed token accounts for a transfer, ensuring one extra account if possible, up to maxInputs.