Documentation Index Fetch the complete documentation index at: https://www.zkcompression.com/llms.txt
Use this file to discover all available pages before exploring further.
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
Delegated Transfer
Install packages in your working directory: npm install @lightprotocol/stateless.js@^0.23.0 \
@lightprotocol/compressed-token@^0.23.0
Install the CLI globally: npm install -g @lightprotocol/zk-compression-cli
Install packages in your working directory: yarn add @lightprotocol/stateless.js@^0.23.0 \
@lightprotocol/compressed-token@^0.23.0
Install the CLI globally: yarn global add @lightprotocol/zk-compression-cli
Install packages in your working directory: pnpm add @lightprotocol/stateless.js@^0.23.0 \
@lightprotocol/compressed-token@^0.23.0
Install the CLI globally: pnpm add -g @lightprotocol/zk-compression-cli
Install packages in your working directory: # npm
npm install @lightprotocol/stateless.js@^0.23.0 \
@lightprotocol/token-interface@^0.1.2
# yarn
yarn add @lightprotocol/stateless.js@^0.23.0 \
@lightprotocol/token-interface@^0.1.2
# pnpm
pnpm add @lightprotocol/stateless.js@^0.23.0 \
@lightprotocol/token-interface@^0.1.2
Install the CLI globally: npm install -g @lightprotocol/zk-compression-cli
# start local test-validator in a separate terminal
light test-validator
In the code examples, use createRpc() without arguments for localnet.
Get an API key from Helius and add to .env: API_KEY =< your-helius-api-key >
In the code examples, use createRpc(RPC_URL) with the devnet URL.
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 ,
payer . publicKey ,
delegate ,
200_000
);
console . log ( "Delegated transfer to:" , recipient . publicKey . toBase58 ());
console . log ( "Amount: 200,000 tokens" );
console . log ( "Tx:" , tx );
})();
import {
Keypair ,
Transaction ,
sendAndConfirmTransaction ,
} from "@solana/web3.js" ;
import { createTransferInterfaceInstructions } from "@lightprotocol/compressed-token/unified" ;
import { rpc , payer , setup } from "../setup.js" ;
( async function () {
const { mint } = await setup ();
const delegate = Keypair . generate ();
const recipient = Keypair . generate ();
// Returns TransactionInstruction[][]. Each inner array is one txn.
const instructions = await createTransferInterfaceInstructions (
rpc ,
payer . publicKey ,
mint ,
200_000 ,
payer . publicKey ,
recipient . publicKey ,
9 ,
{ delegatePubkey: delegate . publicKey }
);
for ( const ixs of instructions ) {
const tx = new Transaction (). add ( ... ixs );
const sig = await sendAndConfirmTransaction ( rpc , tx , [ payer , delegate ]);
console . log ( "Tx:" , sig );
}
})();
import { Keypair , Transaction , sendAndConfirmTransaction } from "@solana/web3.js" ;
import {
createApproveInstructions ,
createTransferInstructions ,
} from "@lightprotocol/token-interface" ;
import { rpc , payer , setup } from "../setup.js" ;
( async function () {
const { mint } = await setup ();
const delegate = Keypair . generate ();
const recipient = Keypair . generate ();
const approveIxs = await createApproveInstructions ({
rpc ,
payer: payer . publicKey ,
owner: payer . publicKey ,
mint ,
delegate: delegate . publicKey ,
amount: 500_000_000 n ,
});
await sendAndConfirmTransaction ( rpc , new Transaction (). add ( ... approveIxs ), [ payer ]);
const transferIxs = await createTransferInstructions ({
rpc ,
payer: payer . publicKey ,
mint ,
sourceOwner: payer . publicKey ,
authority: delegate . publicKey ,
recipient: recipient . publicKey ,
amount: 200_000_000 n ,
});
const sig = await sendAndConfirmTransaction (
rpc ,
new Transaction (). add ( ... transferIxs ),
[ payer , delegate ]
);
console . log ( "Tx:" , sig );
})();
Didn’t find what you were looking for?