Skip to main content
transferInterface with { owner } transfers tokens from an associated token account as an approved delegate. The delegate is the transaction authority. Only the delegate and fee payer sign; the owner’s signature is not required.
  • The recipient is a wallet address (associated token account derived and created internally)
  • The amount must be within the approved allowance
  • Each transfer reduces the remaining allowance
Install or view dedicated agent skills.
npx skills add Lightprotocol/skills
Install orchestrator agent skill or view skill.md:
npx skills add https://zkcompression.com
1

Delegated Transfer

Install packages in your working directory:
npm install @lightprotocol/stateless.js@beta \
            @lightprotocol/compressed-token@beta
Install the CLI globally:
npm install -g @lightprotocol/zk-compression-cli@beta
# start local test-validator in a separate terminal
light test-validator
In the code examples, use createRpc() without arguments for localnet.
import { Keypair } from "@solana/web3.js";
import {
    approveInterface,
    transferInterface,
} from "@lightprotocol/compressed-token/unified";
import { rpc, payer, setup } from "../setup.js";

(async function () {
    const { mint, senderAta } = await setup();

    // Approve: grant delegate permission to spend up to 500,000 tokens
    const delegate = Keypair.generate();
    await approveInterface(
        rpc,
        payer,
        senderAta,
        mint,
        delegate.publicKey,
        500_000,
        payer
    );
    console.log("Approved delegate:", delegate.publicKey.toBase58());

    // Delegate transfers tokens on behalf of the owner
    const recipient = Keypair.generate();
    const tx = await transferInterface(
        rpc,
        payer,
        senderAta,
        mint,
        recipient.publicKey,
        delegate,
        200_000,
        undefined,
        undefined,
        { owner: payer.publicKey }
    );

    console.log("Delegated transfer to:", recipient.publicKey.toBase58());
    console.log("Amount: 200,000 tokens");
    console.log("Tx:", tx);
})();

Approve and revoke

Payments overview


Didn’t find what you were looking for?

Reach out! Telegram | email | Discord