Skip to content

Commit 07ed0e3

Browse files
chore: update docs to new JS beta (#25)
* fixes * rm token pool lang * final * update for wallets * fmt * words
1 parent d13ee7a commit 07ed0e3

42 files changed

Lines changed: 564 additions & 653 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api-reference/json-rpc-methods/getvalidityproof.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ async function generateProofForTransfer() {
210210
console.log(\` Token accounts: ${hashes.length}\`);
211211
console.log(\` Roots: ${validityProof.roots.length}\`);
212212
213-
// This proof is now ready to use with CompressedTokenProgram.transfer()
213+
// This proof is now ready to use with LightTokenProgram.transfer()
214214
console.log('\nProof ready for token transfer instruction');
215215
console.log('Use this with:');
216216
console.log(' recentValidityProof: validityProof.compressedProof');

compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens.mdx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ import {
128128
buildAndSignTx,
129129
} from "@lightprotocol/stateless.js";
130130
import {
131-
CompressedTokenProgram,
131+
LightTokenProgram,
132132
selectMinCompressedTokenAccountsForTransfer,
133133
} from "@lightprotocol/compressed-token";
134134
import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js";
@@ -158,7 +158,7 @@ const amount = bn(1e8);
158158
inputAccounts.map((account) => account.compressedAccount.hash)
159159
);
160160

161-
const ix = await CompressedTokenProgram.transfer({
161+
const ix = await LightTokenProgram.transfer({
162162
payer: payer.publicKey,
163163
inputCompressedTokenAccounts: inputAccounts,
164164
toAddress: recipient.publicKey,
@@ -291,7 +291,7 @@ import * as fs from 'fs';
291291
import * as os from 'os';
292292

293293
// 1. Setup RPC connection and load filesystem wallet for mint operations
294-
// 2. Call createMint() to create SPL mint with token pool for compression
294+
// 2. Call createMint() to create SPL mint with SPL interface for compression
295295
// 3. Call mintTo() to mint compressed tokens to filesystem wallet
296296

297297
const connection: Rpc = createRpc(); // defaults to localhost:8899
@@ -307,7 +307,7 @@ const mintKeypair = Keypair.generate();
307307
await connection.requestAirdrop(payer.publicKey, 1e9);
308308
await new Promise(resolve => setTimeout(resolve, 1000));
309309

310-
// Create SPL mint with token pool for compression
310+
// Create SPL mint with SPL interface for compression
311311
const { mint, transactionSignature } = await createMint(
312312
connection,
313313
payer,
@@ -322,7 +322,7 @@ const mintKeypair = Keypair.generate();
322322
const mintToTxId = await mintTo(
323323
connection,
324324
payer,
325-
mint, // SPL mint with token pool for compression
325+
mint, // SPL mint with SPL interface for compression
326326
payer.publicKey, // recipient address
327327
payer,
328328
10e9,
@@ -344,7 +344,7 @@ Make sure you add your Mint address to `send-tokens.ts`.
344344
// 1. Load wallet and fetch compressed token accounts with getCompressedTokenAccountsByOwner()
345345
// 2. Select accounts for transfer using selectMinCompressedTokenAccountsForTransfer()
346346
// and get validity proof with getValidityProof()
347-
// 3. Create transfer instruction with CompressedTokenProgram.transfer()
347+
// 3. Create transfer instruction with LightTokenProgram.transfer()
348348
// and submit transaction with sendAndConfirmTx()
349349
// 4. Verify balances via getCompressedTokenAccountsByOwner()
350350

@@ -357,7 +357,7 @@ import {
357357
buildAndSignTx,
358358
} from "@lightprotocol/stateless.js";
359359
import {
360-
CompressedTokenProgram,
360+
LightTokenProgram,
361361
selectMinCompressedTokenAccountsForTransfer,
362362
} from "@lightprotocol/compressed-token";
363363
import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js";
@@ -381,7 +381,7 @@ const amount = bn(1e8);
381381
// Step 2: Fetch compressed account hashes from state trees
382382
const compressedTokenAccounts =
383383
await connection.getCompressedTokenAccountsByOwner(owner.publicKey, {
384-
mint, // SPL mint with token pool for compression
384+
mint, // SPL mint with SPL interface for compression
385385
});
386386

387387
if (compressedTokenAccounts.items.length === 0) {
@@ -405,7 +405,7 @@ const amount = bn(1e8);
405405
);
406406

407407
// Step 4: Create transfer instruction that consumes input accounts and creates new output accounts
408-
const ix = await CompressedTokenProgram.transfer({
408+
const ix = await LightTokenProgram.transfer({
409409
payer: payer.publicKey,
410410
inputCompressedTokenAccounts: inputAccounts, // accounts to consume
411411
toAddress: recipient.publicKey,
@@ -454,7 +454,7 @@ Use these integrations to let users convert between regular and compressed forma
454454

455455
<Accordion title="Decompress to Regular SPL">
456456

457-
This example converts compressed tokens to regular SPL format using `CompressedTokenProgram.decompress().`
457+
This example converts compressed tokens to regular SPL format using `LightTokenProgram.decompress().`
458458

459459
```javascript
460460
import {
@@ -467,15 +467,15 @@ import {
467467
} from "@lightprotocol/stateless.js";
468468
import { ComputeBudgetProgram } from "@solana/web3.js";
469469
import {
470-
CompressedTokenProgram,
470+
LightTokenProgram,
471471
getTokenPoolInfos,
472472
selectMinCompressedTokenAccountsForTransfer,
473473
selectTokenPoolInfosForDecompression,
474474
} from "@lightprotocol/compressed-token";
475475

476476
// 1. Setup RPC connection and fetch compressed token accounts with getCompressedTokenAccountsByOwner()
477-
// 2. Select accounts and token pool infos using selectMinCompressedTokenAccountsForTransfer() and selectTokenPoolInfosForDecompression()
478-
// 3. Create decompress instruction with CompressedTokenProgram.decompress() and submit transaction
477+
// 2. Select accounts and SPL interface infos using selectMinCompressedTokenAccountsForTransfer() and selectTokenPoolInfosForDecompression()
478+
// 3. Create decompress instruction with LightTokenProgram.decompress() and submit transaction
479479

480480
// Step 1: Setup RPC connection and define decompression parameters
481481
const connection: Rpc = createRpc("https://mainnet.helius-rpc.com?api-key=<api_key>";);
@@ -510,7 +510,7 @@ const amount = 1e5; // 100K tokens to decompress
510510
);
511511

512512
// 5. Build instruction
513-
const ix = await CompressedTokenProgram.decompress({
513+
const ix = await LightTokenProgram.decompress({
514514
payer: payer.publicKey,
515515
inputCompressedTokenAccounts: inputAccounts,
516516
toAddress: owner.publicKey,
@@ -540,12 +540,12 @@ const amount = 1e5; // 100K tokens to decompress
540540

541541
<Accordion title="Compress Regular SPL Tokens">
542542

543-
This example converts regular SPL tokens to compressed format using `CompressedTokenProgram.compress().`
543+
This example converts regular SPL tokens to compressed format using `LightTokenProgram.compress().`
544544

545545
```typescript
546546
// 1. Setup RPC connection and get user ATA with getOrCreateAssociatedTokenAccount()
547-
// 2. Fetch state tree and token pool infos using getStateTreeInfos() and getTokenPoolInfos()
548-
// 3. Create compress instruction with CompressedTokenProgram.compress() and submit transaction
547+
// 2. Fetch state tree and SPL interface infos using getStateTreeInfos() and getTokenPoolInfos()
548+
// 3. Create compress instruction with LightTokenProgram.compress() and submit transaction
549549

550550

551551
import {
@@ -557,7 +557,7 @@ import {
557557
} from "@lightprotocol/stateless.js";
558558
import { ComputeBudgetProgram } from "@solana/web3.js";
559559
import {
560-
CompressedTokenProgram,
560+
LightTokenProgram,
561561
getTokenPoolInfos,
562562
selectTokenPoolInfo,
563563
} from "@lightprotocol/compressed-token";
@@ -584,20 +584,20 @@ const amount = 1e5; // 100K tokens to compress
584584
const treeInfos = await connection.getStateTreeInfos();
585585
const treeInfo = selectStateTreeInfo(treeInfos);
586586

587-
// Step 4: Fetch and select token pool info for compression
587+
// Step 4: Fetch and select SPL interface info for compression
588588
const tokenPoolInfos = await getTokenPoolInfos(connection, mint);
589589
const tokenPoolInfo = selectTokenPoolInfo(tokenPoolInfos);
590590

591591
// Step 5: Create compress instruction - transfer SPL tokens to pool and create compressed accounts
592-
const compressInstruction = await CompressedTokenProgram.compress({
592+
const compressInstruction = await LightTokenProgram.compress({
593593
payer: payer.publicKey, // fee payer
594594
owner: payer.publicKey, // owner of source SPL tokens
595595
source: sourceTokenAccount.address, // source ATA address
596596
toAddress: payer.publicKey, // recipient of compressed tokens (self)
597597
amount, // amount to compress
598598
mint, // token mint address
599599
outputStateTreeInfo: treeInfo, // state tree for compressed accounts
600-
tokenPoolInfo, // token pool for compression
600+
tokenPoolInfo,
601601
});
602602

603603
// Step 6: Build, sign, and submit compression transaction

compressed-tokens/advanced-guides/airdrop.mdx

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Run this `mint-spl-tokens.ts` to mint SPL tokens to your wallet.
7171
```typescript mint-spl-tokens.ts expandable
7272
// Mint SPL Tokens for Airdrop - LocalNet
7373
// 1. Load wallet and connect to local validator
74-
// 2. Create SPL mint with token pool for compression via createMint()
74+
// 2. Create SPL mint with SPL interface via createMint()
7575
// 3. Create ATA and mint SPL tokens to sender for airdrop preparation
7676
// 4. Output mint address for use in simple-airdrop.ts
7777

@@ -82,7 +82,7 @@ import {
8282
getOrCreateAssociatedTokenAccount,
8383
mintTo,
8484
} from "@solana/spl-token";
85-
import { createTokenPool } from "@lightprotocol/compressed-token";
85+
import { createSplInterface } from "@lightprotocol/compressed-token";
8686
import * as fs from 'fs';
8787
import * as os from 'os';
8888

@@ -95,18 +95,18 @@ const secretKey = JSON.parse(fs.readFileSync(walletPath, 'utf8'));
9595
const payer = Keypair.fromSecretKey(Buffer.from(secretKey));
9696

9797
(async () => {
98-
// Step 2: Create SPL mint with token pool for compression
98+
// Step 2: Create SPL mint with SPL interface
9999
const mint = await createMint(connection, payer, payer.publicKey, null, 9);
100-
const poolTxId = await createTokenPool(connection, payer, mint);
100+
const poolTxId = await createSplInterface(connection, payer, mint);
101101
console.log(`Mint address: ${mint.toBase58()}`);
102-
console.log(`TokenPool created: ${poolTxId}`);
102+
console.log(`SPL interface created: ${poolTxId}`);
103103

104104
// Step 3: Create associated token account for sender
105105
// The sender will send tokens from this account to the recipients as compressed tokens.
106106
const ata = await getOrCreateAssociatedTokenAccount(
107107
connection,
108108
payer,
109-
mint, // SPL mint with token pool for compression
109+
mint, // SPL mint with SPL interface for compression
110110
payer.publicKey
111111
);
112112
console.log(`ATA address: ${ata.address.toBase58()}`);
@@ -116,7 +116,7 @@ const payer = Keypair.fromSecretKey(Buffer.from(secretKey));
116116
const mintToTxId = await mintTo(
117117
connection,
118118
payer,
119-
mint, // SPL mint with token pool for compression
119+
mint, // SPL mint with SPL interface for compression
120120
ata.address, // distributor ATA
121121
payer.publicKey,
122122
100_000_000_000 // amount: 100 tokens with 9 decimals
@@ -141,13 +141,13 @@ Ensure you have the latest `@lightprotocol/stateless.js` and `@lightprotocol/com
141141
```typescript simple-airdrop.ts expandable highlight={29-30,45,74,100}
142142
// Simple Airdrop - LocalNet
143143
// 1. Load wallet and select compression infrastructure with getStateTreeInfos() and getTokenPoolInfos()
144-
// 2. Build CompressedTokenProgram.compress() instruction for multiple recipients in one transaction
144+
// 2. Build LightTokenProgram.compress() instruction for multiple recipients in one transaction
145145
// 3. Execute transaction with compute budget and confirm compression operation with sendAndConfirmTx()
146146
// 4. Verify distribution via getCompressedTokenAccountsByOwner
147147

148148
import { Keypair, PublicKey, ComputeBudgetProgram } from "@solana/web3.js";
149149
import {
150-
CompressedTokenProgram,
150+
LightTokenProgram,
151151
getTokenPoolInfos,
152152
selectTokenPoolInfo,
153153
} from "@lightprotocol/compressed-token";
@@ -175,7 +175,7 @@ const payer = Keypair.fromSecretKey(Buffer.from(secretKey));
175175
const owner = payer;
176176

177177
(async () => {
178-
// Step 2: Select state tree and token pool
178+
// Step 2: Select state tree and SPL interface
179179
const activeStateTrees = await connection.getStateTreeInfos();
180180
const treeInfo = selectStateTreeInfo(activeStateTrees);
181181

@@ -187,7 +187,7 @@ const owner = payer;
187187
const sourceTokenAccount = await getOrCreateAssociatedTokenAccount(
188188
connection,
189189
payer,
190-
mint, // SPL mint with token pool for compression
190+
mint, // SPL mint with SPL interface for compression
191191
payer.publicKey
192192
);
193193

@@ -221,13 +221,13 @@ const owner = payer;
221221
);
222222

223223
// Create compression instruction for multiple recipients in one transaction
224-
const compressInstruction = await CompressedTokenProgram.compress({
224+
const compressInstruction = await LightTokenProgram.compress({
225225
payer: payer.publicKey,
226226
owner: owner.publicKey,
227227
source: sourceTokenAccount.address, // source ATA holding SPL tokens
228228
toAddress: airDropAddresses, // recipient addresses for compressed tokens
229229
amount: amounts, // different amounts for each recipient
230-
mint, // SPL mint with token pool for compression
230+
mint, // SPL mint with SPL interface for compression
231231
tokenPoolInfo: info,
232232
outputStateTreeInfo: treeInfo, // destination state tree
233233
});
@@ -346,7 +346,7 @@ Run the airdrop script with your configured environment:
346346

347347
```typescript expandable
348348
// 1. Load environment and select compression infrastructure with getStateTreeInfos() and getTokenPoolInfos()
349-
// 2. Build CompressedTokenProgram.compress() instruction for multiple recipients in one transaction
349+
// 2. Build LightTokenProgram.compress() instruction for multiple recipients in one transaction
350350
// 3. Execute transaction with compute budget, address lookup table, and confirm with sendAndConfirmTx()
351351
// 4. Verify distribution via getCompressedTokenAccountsByOwner
352352

@@ -356,7 +356,7 @@ import {
356356
ComputeBudgetProgram,
357357
} from '@solana/web3.js';
358358
import {
359-
CompressedTokenProgram,
359+
LightTokenProgram,
360360
getTokenPoolInfos,
361361
selectTokenPoolInfo,
362362
} from '@lightprotocol/compressed-token';
@@ -387,7 +387,7 @@ import { MINT_ADDRESS, PAYER_KEYPAIR, RPC_ENDPOINT } from '../constants';
387387
const treeInfos = await connection.getStateTreeInfos(); // Fixed: removed deprecated getCachedActiveStateTreeInfos
388388
const treeInfo = selectStateTreeInfo(treeInfos);
389389

390-
// 2. Select a token pool
390+
// 2. Select SPL interface
391391
const tokenPoolInfos = await getTokenPoolInfos(connection, mintAddress);
392392
const tokenPoolInfo = selectTokenPoolInfo(tokenPoolInfos);
393393

@@ -415,7 +415,7 @@ import { MINT_ADDRESS, PAYER_KEYPAIR, RPC_ENDPOINT } from '../constants';
415415
}),
416416
];
417417

418-
const compressInstruction = await CompressedTokenProgram.compress({
418+
const compressInstruction = await LightTokenProgram.compress({
419419
payer: payer.publicKey,
420420
owner: owner.publicKey,
421421
source: sourceTokenAccount.address,
@@ -479,12 +479,12 @@ Process recipients in chunks and create batched instructions with optimized comp
479479

480480
```typescript create-instructions.ts expandable
481481

482-
// 1. Process recipients in chunks with selectStateTreeInfo() and selectTokenPoolInfo() for each batch
483-
// 2. Create CompressedTokenProgram.compress() instructions with ComputeBudgetProgram limits for multiple recipients
482+
// 1. Process recipients in chunks with selectStateTreeInfo() and selectTokenPoolInfo() per batch
483+
// 2. Create LightTokenProgram.compress() instructions with ComputeBudgetProgram limits for multiple recipients
484484
// 3. Return batched instructions for optimized large-scale airdrop execution
485485

486486
import {
487-
CompressedTokenProgram,
487+
LightTokenProgram,
488488
TokenPoolInfo,
489489
} from "@lightprotocol/compressed-token";
490490
import {
@@ -561,7 +561,7 @@ export async function createAirdropInstructions({
561561

562562
if (recipientBatch.length === 0) break;
563563

564-
const compressIx = await CompressedTokenProgram.compress({
564+
const compressIx = await LightTokenProgram.compress({
565565
payer,
566566
owner: payer,
567567
source: sourceTokenAccount,
@@ -765,8 +765,8 @@ export async function* signAndSendAirdropBatches(
765765
Put it all together in the main airdrop file.
766766

767767
```typescript airdrop.ts expandable
768-
// 1. Create compressed mint with createMint(), mint supply with mintTo(), get infrastructure with getStateTreeInfos() and getTokenPoolInfos()
769-
// 2. Generate batched compression instructions with createAirdropInstructions() - create CompressedTokenProgram.compress() calls
768+
// 1. Create compressed mint with createMint(), mint supply with mintTo(), get infrastructure with getStateTreeInfos() and getTokenPoolInfos() (SPL interface infos)
769+
// 2. Generate batched compression instructions with createAirdropInstructions() - create LightTokenProgram.compress() calls
770770
// 3. Execute batched airdrop with signAndSendAirdropBatches() - sign transactions and confirm with sendAndConfirmTx() for large-scale distribution
771771

772772
import { Keypair, LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";
@@ -851,7 +851,7 @@ const recipients = [
851851
// 6a: Fetch available state trees for compressed account storage
852852
const stateTreeInfos = await connection.getStateTreeInfos();
853853

854-
// 6b: Get token pool infos for compression operations
854+
// 6b: Get SPL interface infos for compression
855855
const tokenPoolInfos = await getTokenPoolInfos(connection, mint);
856856

857857
// Step 7: Create instruction batches for large-scale airdrop
@@ -863,7 +863,7 @@ const recipients = [
863863
sourceTokenAccount: ata.address, // source ATA holding SPL tokens
864864
mint, // token mint
865865
stateTreeInfos, // state trees for compressed accounts
866-
tokenPoolInfos, // token pools for compression
866+
tokenPoolInfos,
867867
computeUnitPrice: calculateComputeUnitPrice(10_000, 500_000), // dynamic priority fee
868868
});
869869

@@ -913,7 +913,7 @@ import {
913913
} from "@lightprotocol/stateless.js";
914914
import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js";
915915
import {
916-
CompressedTokenProgram,
916+
LightTokenProgram,
917917
getTokenPoolInfos,
918918
selectMinCompressedTokenAccountsForTransfer,
919919
selectTokenPoolInfosForDecompression,
@@ -958,7 +958,7 @@ const connection: Rpc = createRpc(RPC_ENDPOINT);
958958
inputAccounts.map((account) => account.compressedAccount.hash)
959959
);
960960

961-
// 5. Fetch token pool infos
961+
// 5. Fetch SPL interface infos
962962
const tokenPoolInfos = await getTokenPoolInfos(connection, mint);
963963

964964
// 6. Select
@@ -968,7 +968,7 @@ const connection: Rpc = createRpc(RPC_ENDPOINT);
968968
);
969969

970970
// 7. Build instruction
971-
const ix = await CompressedTokenProgram.decompress({
971+
const ix = await LightTokenProgram.decompress({
972972
payer: payer.publicKey,
973973
inputCompressedTokenAccounts: inputAccounts,
974974
toAddress: ata.address,

0 commit comments

Comments
 (0)