Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions extensions/close-mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import { LightTokenProgram } from "@lightprotocol/compressed-token";
import { createSplInterfaceInstruction } from "@lightprotocol/token-interface";
import {
TOKEN_2022_PROGRAM_ID,
ExtensionType,
Expand Down Expand Up @@ -66,9 +66,10 @@ const payer = Keypair.fromSecretKey(
);

// 5. Register the SPL interface PDA with Light Token
const createSplInterfaceIx = await LightTokenProgram.createSplInterface({
const createSplInterfaceIx = createSplInterfaceInstruction({
feePayer: payer.publicKey,
mint: mintKeypair.publicKey,
index: 0,
tokenProgramId: TOKEN_2022_PROGRAM_ID,
});

Expand Down
5 changes: 3 additions & 2 deletions extensions/confidential-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import { LightTokenProgram } from "@lightprotocol/compressed-token";
import { createSplInterfaceInstruction } from "@lightprotocol/token-interface";
import {
ExtensionType,
TOKEN_2022_PROGRAM_ID,
Expand Down Expand Up @@ -116,9 +116,10 @@ function createInitializeConfidentialTransferMintIx(
);

// 5. Register interface PDA with Light Token
const createSplInterfaceIx = await LightTokenProgram.createSplInterface({
const createSplInterfaceIx = createSplInterfaceInstruction({
feePayer: payer.publicKey,
mint: mintKeypair.publicKey,
index: 0,
tokenProgramId: TOKEN_2022_PROGRAM_ID,
});

Expand Down
5 changes: 3 additions & 2 deletions extensions/default-account-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import { LightTokenProgram } from "@lightprotocol/compressed-token";
import { createSplInterfaceInstruction } from "@lightprotocol/token-interface";
import {
TOKEN_2022_PROGRAM_ID,
ExtensionType,
Expand Down Expand Up @@ -67,9 +67,10 @@ const payer = Keypair.fromSecretKey(
);

// 5. Register the SPL interface PDA with Light Token
const createSplInterfaceIx = await LightTokenProgram.createSplInterface({
const createSplInterfaceIx = createSplInterfaceInstruction({
feePayer: payer.publicKey,
mint: mintKeypair.publicKey,
index: 0,
tokenProgramId: TOKEN_2022_PROGRAM_ID,
});

Expand Down
5 changes: 3 additions & 2 deletions extensions/interest-bearing-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import { LightTokenProgram } from "@lightprotocol/compressed-token";
import { createSplInterfaceInstruction } from "@lightprotocol/token-interface";
import {
TOKEN_2022_PROGRAM_ID,
getMintLen,
Expand Down Expand Up @@ -68,9 +68,10 @@ const payer = Keypair.fromSecretKey(

// Instruction 4: Create SPL interface PDA
// Holds Token-2022 tokens when wrapped to light-token
const createSplInterfaceIx = await LightTokenProgram.createSplInterface({
const createSplInterfaceIx = createSplInterfaceInstruction({
feePayer: payer.publicKey,
mint: mintKeypair.publicKey,
index: 0,
tokenProgramId: TOKEN_2022_PROGRAM_ID,
});

Expand Down
5 changes: 3 additions & 2 deletions extensions/metadata-and-metadata-pointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import { LightTokenProgram } from "@lightprotocol/compressed-token";
import { createSplInterfaceInstruction } from "@lightprotocol/token-interface";
import {
TOKEN_2022_PROGRAM_ID,
getMintLen,
Expand Down Expand Up @@ -94,9 +94,10 @@ const payer = Keypair.fromSecretKey(

// Instruction 5: Create SPL interface PDA
// Holds Token-2022 tokens when wrapped to light-token
const createSplInterfaceIx = await LightTokenProgram.createSplInterface({
const createSplInterfaceIx = createSplInterfaceInstruction({
feePayer: payer.publicKey,
mint: mintKeypair.publicKey,
index: 0,
tokenProgramId: TOKEN_2022_PROGRAM_ID,
});

Expand Down
5 changes: 3 additions & 2 deletions extensions/pausable-mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import { LightTokenProgram } from "@lightprotocol/compressed-token";
import { createSplInterfaceInstruction } from "@lightprotocol/token-interface";
import {
ExtensionType,
TOKEN_2022_PROGRAM_ID,
Expand Down Expand Up @@ -64,9 +64,10 @@ const payer = Keypair.fromSecretKey(
);

// 5. Register interface PDA with Light Token
const createSplInterfaceIx = await LightTokenProgram.createSplInterface({
const createSplInterfaceIx = createSplInterfaceInstruction({
feePayer: payer.publicKey,
mint: mintKeypair.publicKey,
index: 0,
tokenProgramId: TOKEN_2022_PROGRAM_ID,
});

Expand Down
5 changes: 3 additions & 2 deletions extensions/permanent-delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import { LightTokenProgram } from "@lightprotocol/compressed-token";
import { createSplInterfaceInstruction } from "@lightprotocol/token-interface";
import {
TOKEN_2022_PROGRAM_ID,
ExtensionType,
Expand Down Expand Up @@ -66,9 +66,10 @@ const payer = Keypair.fromSecretKey(
);

// 5. Register the SPL interface PDA with Light Token
const createSplInterfaceIx = await LightTokenProgram.createSplInterface({
const createSplInterfaceIx = createSplInterfaceInstruction({
feePayer: payer.publicKey,
mint: mintKeypair.publicKey,
index: 0,
tokenProgramId: TOKEN_2022_PROGRAM_ID,
});

Expand Down
8 changes: 5 additions & 3 deletions extensions/token-groups-and-members.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import { LightTokenProgram } from "@lightprotocol/compressed-token";
import { createSplInterfaceInstruction } from "@lightprotocol/token-interface";
import {
TOKEN_2022_PROGRAM_ID,
ExtensionType,
Expand Down Expand Up @@ -82,9 +82,10 @@ const payer = Keypair.fromSecretKey(
});

// Register the group mint with Light Token
const registerGroupIx = await LightTokenProgram.createSplInterface({
const registerGroupIx = createSplInterfaceInstruction({
feePayer: payer.publicKey,
mint: groupMintKeypair.publicKey,
index: 0,
tokenProgramId: TOKEN_2022_PROGRAM_ID,
});

Expand Down Expand Up @@ -153,9 +154,10 @@ const payer = Keypair.fromSecretKey(
});

// Register the member mint with Light Token
const registerMemberIx = await LightTokenProgram.createSplInterface({
const registerMemberIx = createSplInterfaceInstruction({
feePayer: payer.publicKey,
mint: memberMintKeypair.publicKey,
index: 0,
tokenProgramId: TOKEN_2022_PROGRAM_ID,
});

Expand Down
5 changes: 3 additions & 2 deletions extensions/transfer-fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import { LightTokenProgram } from "@lightprotocol/compressed-token";
import { createSplInterfaceInstruction } from "@lightprotocol/token-interface";
import {
TOKEN_2022_PROGRAM_ID,
getMintLen,
Expand Down Expand Up @@ -69,9 +69,10 @@ const payer = Keypair.fromSecretKey(

// Instruction 4: Create SPL interface PDA
// Holds Token-2022 tokens when wrapped to light-token
const createSplInterfaceIx = await LightTokenProgram.createSplInterface({
const createSplInterfaceIx = createSplInterfaceInstruction({
feePayer: payer.publicKey,
mint: mintKeypair.publicKey,
index: 0,
tokenProgramId: TOKEN_2022_PROGRAM_ID,
});

Expand Down
5 changes: 3 additions & 2 deletions extensions/transfer-hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
sendAndConfirmTransaction,
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import { LightTokenProgram } from "@lightprotocol/compressed-token";
import { createSplInterfaceInstruction } from "@lightprotocol/token-interface";
import {
TOKEN_2022_PROGRAM_ID,
getMintLen,
Expand Down Expand Up @@ -68,9 +68,10 @@ const payer = Keypair.fromSecretKey(

// Instruction 4: Create SPL interface PDA
// Holds Token-2022 tokens when wrapped to light-token
const createSplInterfaceIx = await LightTokenProgram.createSplInterface({
const createSplInterfaceIx = createSplInterfaceInstruction({
feePayer: payer.publicKey,
mint: mintKeypair.publicKey,
index: 0,
tokenProgramId: TOKEN_2022_PROGRAM_ID,
});

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
"toolkit:payments": "npm run -w toolkits/payments"
},
"dependencies": {
"@lightprotocol/compressed-token": "^0.23.0",
"@lightprotocol/stateless.js": "^0.23.0",
"@lightprotocol/compressed-token": "^0.23.2",
"@lightprotocol/token-interface": "^0.1.2",
"@lightprotocol/stateless.js": "^0.23.3",
"@solana/spl-token": "^0.4.13",
"@solana/web3.js": "1.98.4",
"dotenv": "^16.5.0"
Expand Down
55 changes: 24 additions & 31 deletions toolkits/gasless-transactions/typescript/gasless-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {
} from "@solana/web3.js";
import { createRpc } from "@lightprotocol/stateless.js";
import {
getAssociatedTokenAddressInterface,
getAtaInterface,
} from "@lightprotocol/compressed-token";
import { createTransferInterfaceInstructions } from "@lightprotocol/compressed-token/unified";
createTransferInstructions,
getAta,
getAtaAddress,
} from "@lightprotocol/token-interface";
import { homedir } from "os";
import { readFileSync } from "fs";
import { setup } from "./setup.js";
Expand Down Expand Up @@ -38,48 +38,41 @@ console.log("Recipient Address:", recipient.publicKey.toBase58());
console.log("\nMint Address:", mint.toBase58());

// Derive ATAs
const senderAta = getAssociatedTokenAddressInterface(mint, sender.publicKey);
const recipientAta = getAssociatedTokenAddressInterface(
mint,
recipient.publicKey,
);
const senderAta = getAtaAddress({ owner: sender.publicKey, mint });
const recipientAta = getAtaAddress({ owner: recipient.publicKey, mint });

console.log("Sender Token Account:", senderAta.toBase58());
console.log("Recipient Token Account:", recipientAta.toBase58());

// Create transfer instruction
const instructions = await createTransferInterfaceInstructions(
const instructions = await createTransferInstructions({
rpc,
sponsor.publicKey,
payer: sponsor.publicKey,
mint,
500_000,
sender.publicKey,
recipient.publicKey,
sourceOwner: sender.publicKey,
authority: sender.publicKey,
recipient: recipient.publicKey,
amount: 500_000,
});
const signature = await sendAndConfirmTransaction(
rpc,
new Transaction().add(...instructions),
[sponsor, sender]
);

// Send — sponsor pays fees, sender authorizes transfer
let signature: string;
for (const ixs of instructions) {
const tx = new Transaction().add(...ixs);
signature = await sendAndConfirmTransaction(rpc, tx, [sponsor, sender]);
}

console.log("\n=== Sponsored Token Payment Complete ===");
console.log("Transaction Signature:", signature!);

// Verify balances
const { parsed: senderBalance } = await getAtaInterface(
const { parsed: senderBalance } = await getAta({
rpc,
senderAta,
sender.publicKey,
owner: sender.publicKey,
mint,
);
const { parsed: recipientBalance } = await getAtaInterface(
});
const { parsed: recipientBalance } = await getAta({
rpc,
recipientAta,
recipient.publicKey,
owner: recipient.publicKey,
mint,
);
});

console.log(
"\nSender Token Account Balance:",
Expand All @@ -91,7 +84,7 @@ console.log("Recipient Address:", recipient.publicKey.toBase58());
);

// Verify fee payer
const tx = await rpc.getTransaction(signature!, {
const tx = await rpc.getTransaction(signature, {
maxSupportedTransactionVersion: 0,
});
const feePayer = tx?.transaction.message.accountKeys[0];
Expand Down
10 changes: 8 additions & 2 deletions toolkits/gasless-transactions/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@
"gasless-transfer": "tsx gasless-transfer.ts"
},
"dependencies": {
"@lightprotocol/compressed-token": "^0.23.0",
"@lightprotocol/stateless.js": "^0.23.0"
"@lightprotocol/token-interface": "^0.1.2",
"@lightprotocol/stateless.js": "^0.23.3",
"@solana/spl-token": "^0.4.13",
"@solana/web3.js": "1.98.4",
"dotenv": "^16.5.0"
},
"devDependencies": {
"tsx": "^4.20.6"
}
}
Loading
Loading