From 6d9312cc408da53838df6c981287900ba86cb63e Mon Sep 17 00:00:00 2001 From: Swenschaeferjohann Date: Wed, 24 Dec 2025 23:58:13 +0100 Subject: [PATCH 1/5] update payments guide --- light-token/toolkits/for-payments.mdx | 189 +++++++++++++++----------- 1 file changed, 107 insertions(+), 82 deletions(-) diff --git a/light-token/toolkits/for-payments.mdx b/light-token/toolkits/for-payments.mdx index 40abc70a..5ac436c9 100644 --- a/light-token/toolkits/for-payments.mdx +++ b/light-token/toolkits/for-payments.mdx @@ -4,21 +4,21 @@ sidebarTitle: "for Stablecoin Payments" description: "Guide to integrate light-token APIs with comparison to SPL." --- -import { CodeCompare } from '/snippets/jsx/code-compare.jsx'; +import { CodeCompare } from "/snippets/jsx/code-compare.jsx"; 1. The light-token API matches the SPL-token API almost entirely, and extends their functionality to include the light-token program in addition to the SPL-token and Token-2022 programs. 2. Your users receive the same stablecoin, just stored more efficiently. -| Creation Cost | SPL | light-token | -|:---------------------|:------------------|:----------------------| -| **Token Account** | ~2,000,000 lamports | ~**17,000** lamports | +| Creation Cost | SPL | light-token | +| :---------------- | :------------------ | :------------------- | +| **Token Account** | ~2,000,000 lamports | ~**17,000** lamports | ### What you will implement - + @@ -63,7 +63,8 @@ import { CodeCompare } from '/snippets/jsx/code-compare.jsx';
SPL Light
-Find full code examples [here](https://github.com/Lightprotocol/examples-light-token/tree/main/toolkits/payments-and-wallets). + Find full code examples + [here](https://github.com/Lightprotocol/examples-light-token/tree/main/toolkits/payments-and-wallets). ## Setup @@ -93,12 +94,7 @@ const rpc = createRpc(RPC_ENDPOINT); ```typescript import { getOrCreateAtaInterface } from "@lightprotocol/compressed-token/unified"; -const ata = await getOrCreateAtaInterface( - rpc, - payer, - mint, - recipient -); +const ata = await getOrCreateAtaInterface(rpc, payer, mint, recipient); // Share ata.parsed.address with sender console.log(ata.parsed.amount); @@ -135,22 +131,23 @@ import { CTOKEN_PROGRAM_ID } from "@lightprotocol/stateless.js"; const ata = getAssociatedTokenAddressInterface(mint, recipient); const tx = new Transaction().add( - createAssociatedTokenAccountInterfaceIdempotentInstruction( - payer.publicKey, - ata, - recipient, - mint, - CTOKEN_PROGRAM_ID - ), - ...(await createLoadAtaInstructions( - rpc, - ata, - recipient, - mint, - payer.publicKey - )) +createAssociatedTokenAccountInterfaceIdempotentInstruction( +payer.publicKey, +ata, +recipient, +mint, +CTOKEN_PROGRAM_ID +), +...(await createLoadAtaInstructions( +rpc, +ata, +recipient, +mint, +payer.publicKey +)) ); -``` + +```` @@ -170,7 +167,7 @@ const tx = new Transaction().add( mint ) ); -``` +```` @@ -201,35 +198,43 @@ await transferInterface( ); ``` -To ensure your recipient's ATA exists you can prepend an idempotent creation instruction in the same atomic transaction: +To ensure your recipient's ATA exists before transferring: ```typescript import { + getOrCreateAtaInterface, + transferInterface, getAssociatedTokenAddressInterface, - createAssociatedTokenAccountInterfaceIdempotentInstruction, } from "@lightprotocol/compressed-token/unified"; -import { CTOKEN_PROGRAM_ID } from "@lightprotocol/stateless.js"; +// Ensure recipient ATA exists (creates if needed) +await getOrCreateAtaInterface(rpc, payer, mint, recipient); + +// Then transfer +const sourceAta = getAssociatedTokenAddressInterface(mint, owner.publicKey); const destinationAta = getAssociatedTokenAddressInterface(mint, recipient); -const createAtaIx = createAssociatedTokenAccountInterfaceIdempotentInstruction( - payer.publicKey, - destinationAta, - recipient, +await transferInterface( + rpc, + payer, + sourceAta, mint, - CTOKEN_PROGRAM_ID + destinationAta, + owner, + amount ); - -new Transaction().add(createAtaIx, transferIx); ``` ```typescript -import { transfer } from "@solana/spl-token"; +import { getOrCreateAssociatedTokenAccount, transfer } from "@solana/spl-token"; +// Ensure recipient ATA exists +await getOrCreateAssociatedTokenAccount(connection, payer, mint, recipient); + +// Then transfer const sourceAta = getAssociatedTokenAddressSync(mint, owner.publicKey); const destinationAta = getAssociatedTokenAddressSync(mint, recipient); - await transfer( connection, payer, @@ -241,41 +246,60 @@ await transfer( ); ``` -With idempotent ATA creation: + + + + ```typescript import { - getAssociatedTokenAddressSync, - createAssociatedTokenAccountIdempotentInstruction, -} from "@solana/spl-token"; + createLoadAtaInstructions, + createTransferInterfaceInstruction, + getAssociatedTokenAddressInterface, +} from "@lightprotocol/compressed-token/unified"; -const destinationAta = getAssociatedTokenAddressSync(mint, recipient); -const createAtaIx = createAssociatedTokenAccountIdempotentInstruction( - payer.publicKey, - destinationAta, - recipient, - mint -); +const sourceAta = getAssociatedTokenAddressInterface(mint, owner.publicKey); +const destinationAta = getAssociatedTokenAddressInterface(mint, recipient); -new Transaction().add(createAtaIx, transferIx); +const tx = new Transaction().add( + ...(await createLoadAtaInstructions( + rpc, + sourceAta, + owner.publicKey, + mint, + payer.publicKey + )), + createTransferInterfaceInstruction( + sourceAta, + destinationAta, + owner.publicKey, + amount + ) +); ``` - - - - +To ensure your recipient's ATA exists, prepend an idempotent creation instruction: ```typescript import { + createAssociatedTokenAccountInterfaceIdempotentInstruction, createLoadAtaInstructions, createTransferInterfaceInstruction, getAssociatedTokenAddressInterface, } from "@lightprotocol/compressed-token/unified"; +import { CTOKEN_PROGRAM_ID } from "@lightprotocol/stateless.js"; const sourceAta = getAssociatedTokenAddressInterface(mint, owner.publicKey); const destinationAta = getAssociatedTokenAddressInterface(mint, recipient); const tx = new Transaction().add( + createAssociatedTokenAccountInterfaceIdempotentInstruction( + payer.publicKey, + destinationAta, + recipient, + mint, + CTOKEN_PROGRAM_ID + ), ...(await createLoadAtaInstructions( rpc, sourceAta, @@ -308,6 +332,29 @@ const tx = new Transaction().add( ); ``` +With idempotent ATA creation: + +```typescript +import { + getAssociatedTokenAddressSync, + createAssociatedTokenAccountIdempotentInstruction, + createTransferInstruction, +} from "@solana/spl-token"; + +const sourceAta = getAssociatedTokenAddressSync(mint, owner.publicKey); +const destinationAta = getAssociatedTokenAddressSync(mint, recipient); + +const tx = new Transaction().add( + createAssociatedTokenAccountIdempotentInstruction( + payer.publicKey, + destinationAta, + recipient, + mint + ), + createTransferInstruction(sourceAta, destinationAta, owner.publicKey, amount) +); +``` + @@ -322,12 +369,7 @@ import { } from "@lightprotocol/compressed-token/unified"; const ata = getAssociatedTokenAddressInterface(mint, owner); -const account = await getAtaInterface( - rpc, - ata, - owner, - mint -); +const account = await getAtaInterface(rpc, ata, owner, mint); console.log(account.parsed.amount); ``` @@ -349,9 +391,7 @@ console.log(account.amount); ```typescript const result = await rpc.getSignaturesForOwnerInterface(owner); -console.log(result.signatures); // Merged + deduplicated -console.log(result.solana); // On-chain txs only -console.log(result.compressed); // Compressed txs only +console.log(result.signatures); // All signatures ``` Use `getSignaturesForAddressInterface(address)` if you want address-specific rather than owner-wide history. @@ -383,15 +423,7 @@ const splAta = getAssociatedTokenAddressSync(mint, owner.publicKey); // c-token ATA destination const ctokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey); -await wrap( - rpc, - payer, - splAta, - ctokenAta, - owner, - mint, - amount -); +await wrap(rpc, payer, splAta, ctokenAta, owner, mint, amount); ``` @@ -439,14 +471,7 @@ import { getAssociatedTokenAddressSync } from "@solana/spl-token"; // SPL ATA must exist const splAta = getAssociatedTokenAddressSync(mint, owner.publicKey); -await unwrap( - rpc, - payer, - splAta, - owner, - mint, - amount -); +await unwrap(rpc, payer, splAta, owner, mint, amount); ``` From e4540e6f532f46a513ea94e11629607c71d9ebc8 Mon Sep 17 00:00:00 2001 From: Swenschaeferjohann Date: Thu, 25 Dec 2025 00:02:20 +0100 Subject: [PATCH 2/5] fmt --- light-token/toolkits/for-payments.mdx | 41 ++++++++++++--------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/light-token/toolkits/for-payments.mdx b/light-token/toolkits/for-payments.mdx index 5ac436c9..c89dbbed 100644 --- a/light-token/toolkits/for-payments.mdx +++ b/light-token/toolkits/for-payments.mdx @@ -120,6 +120,7 @@ console.log(ata.amount); + ```typescript import { createAssociatedTokenAccountInterfaceIdempotentInstruction, @@ -131,23 +132,22 @@ import { CTOKEN_PROGRAM_ID } from "@lightprotocol/stateless.js"; const ata = getAssociatedTokenAddressInterface(mint, recipient); const tx = new Transaction().add( -createAssociatedTokenAccountInterfaceIdempotentInstruction( -payer.publicKey, -ata, -recipient, -mint, -CTOKEN_PROGRAM_ID -), -...(await createLoadAtaInstructions( -rpc, -ata, -recipient, -mint, -payer.publicKey -)) + createAssociatedTokenAccountInterfaceIdempotentInstruction( + payer.publicKey, + ata, + recipient, + mint, + CTOKEN_PROGRAM_ID + ), + ...(await createLoadAtaInstructions( + rpc, + ata, + recipient, + mint, + payer.publicKey + )) ); - -```` +``` @@ -160,14 +160,9 @@ import { const ata = getAssociatedTokenAddressSync(mint, recipient); const tx = new Transaction().add( - createAssociatedTokenAccountInstruction( - payer.publicKey, - ata, - recipient, - mint - ) + createAssociatedTokenAccountInstruction(payer.publicKey, ata, recipient, mint) ); -```` +``` From ef8bfef78e5fcd396d8a98e912e92a873f608a41 Mon Sep 17 00:00:00 2001 From: Swenschaeferjohann Date: Thu, 25 Dec 2025 00:04:31 +0100 Subject: [PATCH 3/5] fmt --- light-token/toolkits/for-payments.mdx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/light-token/toolkits/for-payments.mdx b/light-token/toolkits/for-payments.mdx index c89dbbed..49945eb4 100644 --- a/light-token/toolkits/for-payments.mdx +++ b/light-token/toolkits/for-payments.mdx @@ -122,6 +122,7 @@ console.log(ata.amount); ```typescript +import { Transaction } from "@solana/web3.js"; import { createAssociatedTokenAccountInterfaceIdempotentInstruction, createLoadAtaInstructions, @@ -222,7 +223,11 @@ await transferInterface( ```typescript -import { getOrCreateAssociatedTokenAccount, transfer } from "@solana/spl-token"; +import { + getAssociatedTokenAddressSync, + getOrCreateAssociatedTokenAccount, + transfer, +} from "@solana/spl-token"; // Ensure recipient ATA exists await getOrCreateAssociatedTokenAccount(connection, payer, mint, recipient); @@ -247,6 +252,7 @@ await transfer( ```typescript +import { Transaction } from "@solana/web3.js"; import { createLoadAtaInstructions, createTransferInterfaceInstruction, @@ -276,6 +282,7 @@ const tx = new Transaction().add( To ensure your recipient's ATA exists, prepend an idempotent creation instruction: ```typescript +import { Transaction } from "@solana/web3.js"; import { createAssociatedTokenAccountInterfaceIdempotentInstruction, createLoadAtaInstructions, @@ -425,6 +432,7 @@ await wrap(rpc, payer, splAta, ctokenAta, owner, mint, amount); ```typescript +import { Transaction } from "@solana/web3.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { createWrapInstruction, @@ -473,6 +481,7 @@ await unwrap(rpc, payer, splAta, owner, mint, amount); ```typescript +import { Transaction } from "@solana/web3.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { createLoadAtaInstructions, From acc862825c098f9c009bf1449d3dbf0284048060 Mon Sep 17 00:00:00 2001 From: Swenschaeferjohann Date: Thu, 25 Dec 2025 00:08:19 +0100 Subject: [PATCH 4/5] fmt --- light-token/toolkits/for-launchpads.mdx | 372 ++++++++++++------------ light-token/toolkits/for-wallets.mdx | 8 +- 2 files changed, 196 insertions(+), 184 deletions(-) diff --git a/light-token/toolkits/for-launchpads.mdx b/light-token/toolkits/for-launchpads.mdx index e73ebca6..aa37cd62 100644 --- a/light-token/toolkits/for-launchpads.mdx +++ b/light-token/toolkits/for-launchpads.mdx @@ -4,23 +4,23 @@ sidebarTitle: "for Launchpads" description: "Guide to add light-token APIs to your Launchpad Application." --- -import { CodeCompare } from '/snippets/jsx/code-compare.jsx'; +import { CodeCompare } from "/snippets/jsx/code-compare.jsx"; 1. light-token follows similar API patterns like SPL and simply adds an interface suffix. 2. Token accounts cost ~200x less to create than SPL accounts. 3. Mints are rent-free with built-in token metadata. -| Creation Cost | SPL | light-token | -|:---------------------|:------------------|:----------------------| -| **Mint Account** | ~1,500,000 lamports | **15,000** lamports | -| **Token Account** | ~2,000,000 lamports | ~**17,000** lamports | +| Creation Cost | SPL | light-token | +| :---------------- | :------------------ | :------------------- | +| **Mint Account** | ~1,500,000 lamports | **15,000** lamports | +| **Token Account** | ~2,000,000 lamports | ~**17,000** lamports | ### What you will implement - + @@ -60,7 +60,8 @@ import { CodeCompare } from '/snippets/jsx/code-compare.jsx';
SPL Light
-Find devnet examples [here](https://github.com/Lightprotocol/light-token-toolkits). + Find devnet examples + [here](https://github.com/Lightprotocol/light-token-toolkits). ## Setup @@ -89,29 +90,32 @@ const rpc = createRpc(RPC_ENDPOINT); ```typescript -import { Keypair } from '@solana/web3.js'; -import { createRpc } from '@lightprotocol/stateless.js'; -import { createMintInterface, createTokenMetadata } from '@lightprotocol/compressed-token'; +import { Keypair } from "@solana/web3.js"; +import { createRpc } from "@lightprotocol/stateless.js"; +import { + createMintInterface, + createTokenMetadata, +} from "@lightprotocol/compressed-token"; const mintSigner = Keypair.generate(); const { mint, transactionSignature } = await createMintInterface( - rpc, - payer, - payer, // mintAuthority - null, // freezeAuthority - 9, // decimals - mintSigner, - undefined, - undefined, - createTokenMetadata( - 'My Launchpad Token', - 'MLT', - 'https://example.com/metadata.json' - ), + rpc, + payer, + payer, // mintAuthority + null, // freezeAuthority + 9, // decimals + mintSigner, + undefined, + undefined, + createTokenMetadata( + "My Launchpad Token", + "MLT", + "https://example.com/metadata.json" + ) ); -console.log('Mint created:', mint.toBase58()); +console.log("Mint created:", mint.toBase58()); ``` @@ -121,22 +125,16 @@ import { createMint } from "@solana/spl-token"; import { Metaplex } from "@metaplex-foundation/js"; // SPL requires separate mint creation + Metaplex metadata -const mint = await createMint( - connection, - payer, - payer.publicKey, - null, - 9 -); +const mint = await createMint(connection, payer, payer.publicKey, null, 9); // Then add metadata via Metaplex (additional transaction) const metaplex = Metaplex.make(connection); await metaplex.nfts().create({ - name: 'My Launchpad Token', - symbol: 'MLT', - uri: 'https://example.com/metadata.json', - sellerFeeBasisPoints: 0, - useNewMint: mint, + name: "My Launchpad Token", + symbol: "MLT", + uri: "https://example.com/metadata.json", + sellerFeeBasisPoints: 0, + useNewMint: mint, }); ``` @@ -146,53 +144,59 @@ await metaplex.nfts().create({ ```typescript -import { Keypair, ComputeBudgetProgram } from '@solana/web3.js'; +import { Keypair, ComputeBudgetProgram } from "@solana/web3.js"; import { - buildAndSignTx, - sendAndConfirmTx, - selectAddressTreeInfoV2, - selectStateTreeInfo, -} from '@lightprotocol/stateless.js'; + buildAndSignTx, + sendAndConfirmTx, + selectAddressTreeInfoV2, + selectStateTreeInfo, +} from "@lightprotocol/stateless.js"; import { - createMintInstruction, - createTokenMetadata, - findMintAddress, -} from '@lightprotocol/compressed-token'; + createMintInstruction, + createTokenMetadata, + findMintAddress, +} from "@lightprotocol/compressed-token"; const mintSigner = Keypair.generate(); const decimals = 9; // Get tree infos -const addressTreeInfo = selectAddressTreeInfoV2(await rpc.getAddressTreeInfos()); +const addressTreeInfo = selectAddressTreeInfoV2( + await rpc.getAddressTreeInfos() +); const stateTreeInfo = selectStateTreeInfo(await rpc.getStateTreeInfos()); // Get validity proof for address creation const [mintPda] = findMintAddress(mintSigner.publicKey); const validityProof = await rpc.getValidityProofV0( - [], - [{ address: mintPda, tree: addressTreeInfo.tree }], + [], + [{ address: mintPda, tree: addressTreeInfo.tree }] ); // Create instruction const ix = createMintInstruction( - mintSigner.publicKey, - decimals, - payer.publicKey, // mintAuthority - null, // freezeAuthority - payer.publicKey, - validityProof, - addressTreeInfo, - stateTreeInfo, - createTokenMetadata('My Launchpad Token', 'MLT', 'https://example.com/metadata.json'), + mintSigner.publicKey, + decimals, + payer.publicKey, // mintAuthority + null, // freezeAuthority + payer.publicKey, + validityProof, + addressTreeInfo, + stateTreeInfo, + createTokenMetadata( + "My Launchpad Token", + "MLT", + "https://example.com/metadata.json" + ) ); // Build and send transaction const { blockhash } = await rpc.getLatestBlockhash(); const tx = buildAndSignTx( - [ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), ix], - payer, - blockhash, - [mintSigner], + [ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), ix], + payer, + blockhash, + [mintSigner] ); const signature = await sendAndConfirmTx(rpc, tx); ``` @@ -208,14 +212,9 @@ const signature = await sendAndConfirmTx(rpc, tx); ```typescript import { getOrCreateAtaInterface } from "@lightprotocol/compressed-token"; -const ata = await getOrCreateAtaInterface( - rpc, - payer, - mint, - buyer.publicKey -); +const ata = await getOrCreateAtaInterface(rpc, payer, mint, buyer.publicKey); -console.log('User ATA:', ata.parsed.address.toBase58()); +console.log("User ATA:", ata.parsed.address.toBase58()); ``` @@ -224,13 +223,13 @@ console.log('User ATA:', ata.parsed.address.toBase58()); import { getOrCreateAssociatedTokenAccount } from "@solana/spl-token"; const ata = await getOrCreateAssociatedTokenAccount( - connection, - payer, - mint, - buyer.publicKey + connection, + payer, + mint, + buyer.publicKey ); -console.log('User ATA:', ata.address.toBase58()); +console.log("User ATA:", ata.address.toBase58()); ``` @@ -241,29 +240,29 @@ console.log('User ATA:', ata.address.toBase58()); ```typescript import { Transaction } from "@solana/web3.js"; import { - createAssociatedTokenAccountInterfaceIdempotentInstruction, - createLoadAtaInstructions, - getAssociatedTokenAddressInterface, + createAssociatedTokenAccountInterfaceIdempotentInstruction, + createLoadAtaInstructions, + getAssociatedTokenAddressInterface, } from "@lightprotocol/compressed-token/unified"; import { CTOKEN_PROGRAM_ID } from "@lightprotocol/stateless.js"; const ata = getAssociatedTokenAddressInterface(mint, buyer.publicKey); const tx = new Transaction().add( - createAssociatedTokenAccountInterfaceIdempotentInstruction( - payer.publicKey, - ata, - buyer.publicKey, - mint, - CTOKEN_PROGRAM_ID - ), - ...(await createLoadAtaInstructions( - rpc, - ata, - buyer.publicKey, - mint, - payer.publicKey - )) + createAssociatedTokenAccountInterfaceIdempotentInstruction( + payer.publicKey, + ata, + buyer.publicKey, + mint, + CTOKEN_PROGRAM_ID + ), + ...(await createLoadAtaInstructions( + rpc, + ata, + buyer.publicKey, + mint, + payer.publicKey + )) ); ``` @@ -278,21 +277,24 @@ When a user buys from the bonding curve, mint tokens to their account. ```typescript -import { mintToInterface, getAssociatedTokenAddressInterface } from "@lightprotocol/compressed-token"; +import { + mintToInterface, + getAssociatedTokenAddressInterface, +} from "@lightprotocol/compressed-token"; const buyerAta = getAssociatedTokenAddressInterface(mint, buyer.publicKey); const amount = 1_000_000_000; // 1 token with 9 decimals const signature = await mintToInterface( - rpc, - payer, - mint, - buyerAta, - mintAuthority, // bonding curve PDA or keypair - amount, + rpc, + payer, + mint, + buyerAta, + mintAuthority, // bonding curve PDA or keypair + amount ); -console.log('Minted tokens to buyer:', signature); +console.log("Minted tokens to buyer:", signature); ``` @@ -304,15 +306,15 @@ const buyerAta = getAssociatedTokenAddressSync(mint, buyer.publicKey); const amount = 1_000_000_000; const signature = await mintTo( - connection, - payer, - mint, - buyerAta, - mintAuthority, - amount + connection, + payer, + mint, + buyerAta, + mintAuthority, + amount ); -console.log('Minted tokens to buyer:', signature); +console.log("Minted tokens to buyer:", signature); ``` @@ -321,18 +323,18 @@ console.log('Minted tokens to buyer:', signature); ```typescript -import { ComputeBudgetProgram } from '@solana/web3.js'; +import { ComputeBudgetProgram } from "@solana/web3.js"; import { - buildAndSignTx, - sendAndConfirmTx, - bn, - DerivationMode, -} from '@lightprotocol/stateless.js'; + buildAndSignTx, + sendAndConfirmTx, + bn, + DerivationMode, +} from "@lightprotocol/stateless.js"; import { - createMintToInterfaceInstruction, - getMintInterface, - getAssociatedTokenAddressInterface, -} from '@lightprotocol/compressed-token'; + createMintToInterfaceInstruction, + getMintInterface, + getAssociatedTokenAddressInterface, +} from "@lightprotocol/compressed-token"; const buyerAta = getAssociatedTokenAddressInterface(mint, buyer.publicKey); const amount = 1_000_000_000; @@ -343,35 +345,37 @@ const mintInterface = await getMintInterface(rpc, mint); // Get validity proof for the mint let validityProof; if (mintInterface.merkleContext) { - validityProof = await rpc.getValidityProofV2( - [{ - hash: bn(mintInterface.merkleContext.hash), - leafIndex: mintInterface.merkleContext.leafIndex, - treeInfo: mintInterface.merkleContext.treeInfo, - proveByIndex: mintInterface.merkleContext.proveByIndex, - }], - [], - DerivationMode.compressible, - ); + validityProof = await rpc.getValidityProofV2( + [ + { + hash: bn(mintInterface.merkleContext.hash), + leafIndex: mintInterface.merkleContext.leafIndex, + treeInfo: mintInterface.merkleContext.treeInfo, + proveByIndex: mintInterface.merkleContext.proveByIndex, + }, + ], + [], + DerivationMode.compressible + ); } // Create instruction const ix = createMintToInterfaceInstruction( - mintInterface, - buyerAta, - mintAuthority.publicKey, // bonding curve authority - payer.publicKey, - amount, - validityProof, + mintInterface, + buyerAta, + mintAuthority.publicKey, // bonding curve authority + payer.publicKey, + amount, + validityProof ); // Build and send transaction const { blockhash } = await rpc.getLatestBlockhash(); const tx = buildAndSignTx( - [ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), ix], - payer, - blockhash, - [mintAuthority], // include mint authority as signer + [ComputeBudgetProgram.setComputeUnitLimit({ units: 500_000 }), ix], + payer, + blockhash, + [mintAuthority] // include mint authority as signer ); const signature = await sendAndConfirmTx(rpc, tx); ``` @@ -388,8 +392,8 @@ When a user sells, transfer tokens back to the bonding curve account. ```typescript import { - transferInterface, - getAssociatedTokenAddressInterface, + transferInterface, + getAssociatedTokenAddressInterface, } from "@lightprotocol/compressed-token"; const sellerAta = getAssociatedTokenAddressInterface(mint, seller.publicKey); @@ -397,16 +401,16 @@ const curveAta = getAssociatedTokenAddressInterface(mint, bondingCurvePda); const amount = 500_000_000; // 0.5 tokens const signature = await transferInterface( - rpc, - payer, - sellerAta, - mint, - curveAta, - seller, // owner (must be Signer) - amount, + rpc, + payer, + sellerAta, + mint, + curveAta, + seller, // owner (must be Signer) + amount ); -console.log('Sold tokens:', signature); +console.log("Sold tokens:", signature); ``` @@ -419,15 +423,15 @@ const curveAta = getAssociatedTokenAddressSync(mint, bondingCurvePda); const amount = 500_000_000; const signature = await transfer( - connection, - payer, - sellerAta, - curveAta, - seller, - amount + connection, + payer, + sellerAta, + curveAta, + seller, + amount ); -console.log('Sold tokens:', signature); +console.log("Sold tokens:", signature); ``` @@ -438,9 +442,9 @@ console.log('Sold tokens:', signature); ```typescript import { Transaction } from "@solana/web3.js"; import { - createLoadAtaInstructions, - createTransferInterfaceInstruction, - getAssociatedTokenAddressInterface, + createLoadAtaInstructions, + createTransferInterfaceInstruction, + getAssociatedTokenAddressInterface, } from "@lightprotocol/compressed-token/unified"; const sellerAta = getAssociatedTokenAddressInterface(mint, seller.publicKey); @@ -448,19 +452,19 @@ const curveAta = getAssociatedTokenAddressInterface(mint, bondingCurvePda); const amount = 500_000_000; const tx = new Transaction().add( - ...(await createLoadAtaInstructions( - rpc, - sellerAta, - seller.publicKey, - mint, - payer.publicKey - )), - createTransferInterfaceInstruction( - sellerAta, - curveAta, - seller.publicKey, - amount - ) + ...(await createLoadAtaInstructions( + rpc, + sellerAta, + seller.publicKey, + mint, + payer.publicKey + )), + createTransferInterfaceInstruction( + sellerAta, + curveAta, + seller.publicKey, + amount + ) ); ``` @@ -471,19 +475,14 @@ const tx = new Transaction().add( ```typescript import { - getAssociatedTokenAddressInterface, - getAtaInterface, + getAssociatedTokenAddressInterface, + getAtaInterface, } from "@lightprotocol/compressed-token"; const ata = getAssociatedTokenAddressInterface(mint, owner); -const account = await getAtaInterface( - rpc, - ata, - owner, - mint -); +const account = await getAtaInterface(rpc, ata, owner, mint); -console.log('Balance:', account.parsed.amount.toString()); +console.log("Balance:", account.parsed.amount.toString()); ``` @@ -494,7 +493,7 @@ import { getAccount, getAssociatedTokenAddressSync } from "@solana/spl-token"; const ata = getAssociatedTokenAddressSync(mint, owner); const account = await getAccount(connection, ata); -console.log('Balance:', account.amount.toString()); +console.log("Balance:", account.amount.toString()); ``` @@ -504,13 +503,22 @@ console.log('Balance:', account.amount.toString()); If your bonding curve logic is on-chain and needs to CPI into the light-token program, see the Program Guide tabs in: - + invoke / invoke_signed examples - + MintToCTokenCpi builder - + TransferInterfaceCpi builder diff --git a/light-token/toolkits/for-wallets.mdx b/light-token/toolkits/for-wallets.mdx index 39816163..9ae1c69f 100644 --- a/light-token/toolkits/for-wallets.mdx +++ b/light-token/toolkits/for-wallets.mdx @@ -125,6 +125,7 @@ console.log(ata.amount); ```typescript +import { Transaction } from "@solana/web3.js"; import { createAssociatedTokenAccountInterfaceIdempotentInstruction, createLoadAtaInstructions, @@ -266,6 +267,7 @@ new Transaction().add(createAtaIx, transferIx); ```typescript +import { Transaction } from "@solana/web3.js"; import { createLoadAtaInstructions, createTransferInterfaceInstruction, @@ -400,12 +402,13 @@ await wrap( ```typescript +import { Transaction } from "@solana/web3.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { createWrapInstruction, getAssociatedTokenAddressInterface, + getSplInterfaceInfos, } from "@lightprotocol/compressed-token"; -import { getSplInterfaceInfos } from "@lightprotocol/compressed-token"; const splAta = getAssociatedTokenAddressSync(mint, owner.publicKey); const ctokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey); @@ -455,13 +458,14 @@ await unwrap( ```typescript +import { Transaction } from "@solana/web3.js"; import { getAssociatedTokenAddressSync } from "@solana/spl-token"; import { createLoadAtaInstructions, createUnwrapInstruction, getAssociatedTokenAddressInterface, + getSplInterfaceInfos, } from "@lightprotocol/compressed-token"; -import { getSplInterfaceInfos } from "@lightprotocol/compressed-token"; const ctokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey); const splAta = getAssociatedTokenAddressSync(mint, owner.publicKey); From fffe2291d5275f3bb5906f5d663fd9d02109a0a2 Mon Sep 17 00:00:00 2001 From: Swenschaeferjohann Date: Thu, 25 Dec 2025 00:10:59 +0100 Subject: [PATCH 5/5] resolve link rot --- light-token/cookbook/create-ata.mdx | 2 +- light-token/cookbook/create-mint.mdx | 2 +- light-token/cookbook/create-token-account.mdx | 2 +- light-token/toolkits/for-launchpads.mdx | 2 +- snippets/overview-tables/cookbook-guides-table.mdx | 2 +- snippets/overview-tables/light-mint-guides-table.mdx | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/light-token/cookbook/create-ata.mdx b/light-token/cookbook/create-ata.mdx index 8c738853..a82b9209 100644 --- a/light-token/cookbook/create-ata.mdx +++ b/light-token/cookbook/create-ata.mdx @@ -538,6 +538,6 @@ pub fn process_create_ata2_invoke_signed( title="Learn how to mint light-tokens" icon="chevron-right" color="#0066ff" - href="/light-token/cookbook/mint-tokens" + href="/light-token/cookbook/mint-to" horizontal /> diff --git a/light-token/cookbook/create-mint.mdx b/light-token/cookbook/create-mint.mdx index 1a85d6e4..975a5d4d 100644 --- a/light-token/cookbook/create-mint.mdx +++ b/light-token/cookbook/create-mint.mdx @@ -837,7 +837,7 @@ pub fn process_create_cmint_with_pda_authority( title="Learn how to mint tokens to light-token accounts." icon="chevron-right" color="#0066ff" - href="/light-token/cookbook/mint-tokens" + href="/light-token/cookbook/mint-to" horizontal /> diff --git a/light-token/cookbook/create-token-account.mdx b/light-token/cookbook/create-token-account.mdx index 8bea1b05..7a0a68a4 100644 --- a/light-token/cookbook/create-token-account.mdx +++ b/light-token/cookbook/create-token-account.mdx @@ -395,6 +395,6 @@ pub fn process_create_token_account_invoke_signed( title="Learn how to mint tokens to light-token accounts" icon="chevron-right" color="#0066ff" - href="/light-token/cookbook/mint-tokens" + href="/light-token/cookbook/mint-to" horizontal /> diff --git a/light-token/toolkits/for-launchpads.mdx b/light-token/toolkits/for-launchpads.mdx index aa37cd62..b1c89ac0 100644 --- a/light-token/toolkits/for-launchpads.mdx +++ b/light-token/toolkits/for-launchpads.mdx @@ -511,7 +511,7 @@ If your bonding curve logic is on-chain and needs to CPI into the light-token pr MintToCTokenCpi builder diff --git a/snippets/overview-tables/cookbook-guides-table.mdx b/snippets/overview-tables/cookbook-guides-table.mdx index 67ab5a1e..b5f9c602 100644 --- a/snippets/overview-tables/cookbook-guides-table.mdx +++ b/snippets/overview-tables/cookbook-guides-table.mdx @@ -38,7 +38,7 @@ x - Mint To + Mint To Mint tokens to light-token accounts x x diff --git a/snippets/overview-tables/light-mint-guides-table.mdx b/snippets/overview-tables/light-mint-guides-table.mdx index 59787bee..52088e41 100644 --- a/snippets/overview-tables/light-mint-guides-table.mdx +++ b/snippets/overview-tables/light-mint-guides-table.mdx @@ -1,4 +1,4 @@ | | | | :---- | :---------- | | [Create Mint Account](/light-token/cookbook/create-mint) | Program and client guide to create light-mints with token metadata | -| [Mint Tokens](/light-token/cookbook/mint-tokens) | Mint tokens to light-token accounts | +| [Mint Tokens](/light-token/cookbook/mint-to) | Mint tokens to light-token accounts |