Skip to main content
SPLLight
TransfercreateTransferInstruction()createTransferInterfaceInstructions()
Use the payments agent skill to add light-token payment support to your project:
Add the marketplace and install:
/plugin marketplace add Lightprotocol/skills
/plugin install solana-rent-free-dev
For orchestration, install the general skill:
npx skills add https://zkcompression.com

How it works

  1. Create the transfer instructions with createTransferInterfaceInstructions().
  2. Add a memo instruction to the transfer transaction (the last batch).
  3. Both instructions execute atomically in the same transaction.

Setup

npm install @lightprotocol/compressed-token@beta \
            @lightprotocol/stateless.js@beta
Additionally install the memo program package:
npm install @solana/spl-memo
import { createRpc } from "@lightprotocol/stateless.js";

const rpc = createRpc(RPC_ENDPOINT);

Send a payment with memo

import { Transaction, sendAndConfirmTransaction, TransactionInstruction, PublicKey } from "@solana/web3.js";
import {
  createTransferInterfaceInstructions,
  sliceLast,
} from "@lightprotocol/compressed-token/unified";

const MEMO_PROGRAM_ID = new PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");

const instructions = await createTransferInterfaceInstructions(
  rpc,
  payer.publicKey,
  mint,
  amount,
  owner.publicKey,
  recipient
);

const { rest: loadInstructions, last: transferInstructions } = sliceLast(instructions);

// Send load transactions first (if any)
for (const ixs of loadInstructions) {
  const tx = new Transaction().add(...ixs);
  await sendAndConfirmTransaction(rpc, tx, [payer, owner]);
}

// Add memo to the transfer transaction
const memoIx = new TransactionInstruction({
  keys: [],
  programId: MEMO_PROGRAM_ID,
  data: Buffer.from("INV-2024-001"),
});

const transferTx = new Transaction().add(...transferInstructions, memoIx);
await sendAndConfirmTransaction(rpc, transferTx, [payer, owner]);

Read memo from transaction logs

After the transaction confirms, the memo appears in the transaction logs:
const txDetails = await rpc.getTransaction(signature, {
  maxSupportedTransactionVersion: 0,
});

// Look for memo program log entries
const logs = txDetails?.meta?.logMessages || [];
const memoLogs = logs.filter((log) =>
  log.includes("Program MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr")
);
console.log("Memo logs:", memoLogs);

Basic payment

Send a single transfer without memo.

Verify payments

Query balances and transaction history.

Batch payments

Pack multiple transfers into one transaction.

Didn’t find what you were looking for?

Reach out! Telegram | email | Discord