Is there a Solana Tool made that allows you to send the same amount of an spl token to multiple addresses with an added custom memoID?
I've seen a handful of tools that allow you to send to multiple wallets but none that actually let you add a custom memoID to each transaction, as I need.
UPDATE:
I have managed to create a script that sends single spl token transactions with a memo id. I am struggling to follow either answer to upgrade this script to send multiple transactions.
import { getOrCreateAssociatedTokenAccount, createTransferInstruction } from "@solana/spl-token";
import { Connection, Keypair, ParsedAccountData, PublicKey, sendAndConfirmTransaction, SystemProgram, Transaction, TransactionInstruction } from "@solana/web3.js";
import secret from './guideSecret.json';
import importedRecipientAddress from './recipients.csv'
const RPC = 'https://solana-api.projectserum.com';
const SOLANA_CONNECTION = new Connection(RPC);
const FROM_KEYPAIR = Keypair.fromSecretKey(new Uint8Array(secret));
const DESTINATION_WALLET = 'importedRecipientAddress';
const MINT_ADDRESS = 'kinXdEcpDQeHPEuQnqmUgtYykqKGVFq6CeVX5iAHJq6';
const TRANSFER_AMOUNT = 1;
async function getNumberDecimals(MINT_ADDRESS: string):Promise<number> {
const info = await SOLANA_CONNECTION.getParsedAccountInfo(new PublicKey(MINT_ADDRESS));
const result = (info.value?.data as ParsedAccountData).parsed.info.decimals as number;
return result;
}
async function sendTokens(message: string) {
console.log(`Sending ${TRANSFER_AMOUNT} ${(MINT_ADDRESS)} from ${(FROM_KEYPAIR.publicKey.toString())} to ${(DESTINATION_WALLET)}.`)
//Step 1
console.log(`1 - Getting Source Token Account`);
let sourceAccount = await getOrCreateAssociatedTokenAccount(
SOLANA_CONNECTION,
FROM_KEYPAIR,
new PublicKey(MINT_ADDRESS),
FROM_KEYPAIR.publicKey
);
console.log(` Source Account: ${sourceAccount.address.toString()}`);
//Step 2
console.log(`2 - Getting Destination Token Account`);
let destinationAccount = await getOrCreateAssociatedTokenAccount(
SOLANA_CONNECTION,
FROM_KEYPAIR,
new PublicKey(MINT_ADDRESS),
new PublicKey(DESTINATION_WALLET)
);
console.log(` Destination Account: ${destinationAccount.address.toString()}`);
//Step 3
console.log(`3 - Fetching Number of Decimals for Mint: ${MINT_ADDRESS}`);
const numberDecimals = await getNumberDecimals(MINT_ADDRESS);
console.log(` Number of Decimals: ${numberDecimals}`);
//Step 4
console.log(`4 - Creating Transaction`);
const tx = new Transaction();
tx.add(createTransferInstruction(
sourceAccount.address,
destinationAccount.address,
FROM_KEYPAIR.publicKey,
TRANSFER_AMOUNT * Math.pow(10, numberDecimals)
))
// Step 5
console.log(`5 - Adding Memo ID to Transaction`);
tx.add(new TransactionInstruction({
keys: [{ pubkey: FROM_KEYPAIR.publicKey, isSigner: true, isWritable: true }],
data: Buffer.from(message, "utf-8"),
programId: new PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),
}))
console.log(`6 - Sending Transaction`);
const latestBlockHash = await SOLANA_CONNECTION.getLatestBlockhash('confirmed');
tx.recentBlockhash = await latestBlockHash.blockhash;
const signature = await sendAndConfirmTransaction(SOLANA_CONNECTION,tx,[FROM_KEYPAIR]);
console.log(
'\x1b[32m', //Green Text
` Transaction Success!🎉`,
`\n https://explorer.solana.com/tx/${signature}?cluster=mainnet-beta`
);
}
sendTokens("KRE AppIndex: 394");