@@ -5,158 +5,50 @@ description: "Light token accounts follow the same layout as SPL-token accounts,
55keywords : ["streaming tokens for solana apps", "scalable token distribution on solana", "token streaming for developers"]
66---
77
8- import ToolkitsSetup from " /snippets/setup/toolkits-setup.mdx" ;
8+ import WarmUpAction from " /snippets/code-snippets/light-token/warm-up/warm-up-action.mdx" ;
9+ import WarmUpInstruction from " /snippets/code-snippets/light-token/warm-up/warm-up-instruction.mdx" ;
910
10- When a market becomes inactive, its token accounts and related PDAs will be compressed - their state is committed and effectively frozen until a client decompresses it.
11+ When a market becomes inactive, its token accounts and related PDAs will
12+ be compressed automatically (cold storage).
13+ The state is cryptographically preserved on the Solana ledger.
1114While compressed, pure on-chain lookups will return uninitialized.
1215
13- Your indexer should keep tracking, quoting, and routing markets even if the on-chain account shows ` is_initialized: false ` , ` is_compressed: true ` . To trade a cold market, the first client must prepend an idempotent decompress "warm up" instruction.
16+ Your indexer should keep tracking, quoting, and routing markets even if the
17+ on-chain account shows ` is_initialized: false ` , ` is_compressed: true ` .
18+ To trade a cold market, the first client must prepend an
19+ idempotent decompress "warm up" instruction.
1420
1521<Info >
1622 Find the source code
17- [ here] ( https://github.com/Lightprotocol/light-protocol/blob /main/js/compressed-token/tests/e2e/load-ata-standard.test.ts ) .
23+ [ here] ( https://github.com/Lightprotocol/examples- light-token/tree /main/toolkits/indexing-tokens ) .
1824</Info >
1925
20- ## Setup
21-
22- <ToolkitsSetup />
23-
2426<Steps >
2527<Step >
26- ### Load Compressed Tokens to Hot Balance
27-
28- <CodeGroup >
29- ``` typescript Action
30- import { Keypair } from " @solana/web3.js" ;
31- import { createRpc , bn } from " @lightprotocol/stateless.js" ;
32- import {
33- createMint ,
34- mintTo ,
35- loadAta ,
36- getAssociatedTokenAddressInterface ,
37- } from " @lightprotocol/compressed-token" ;
38-
39- async function main() {
40- const rpc = createRpc ();
41- const payer = Keypair .generate ();
42- await rpc .requestAirdrop (payer .publicKey , 10e9 );
43-
44- const owner = Keypair .generate ();
45- await rpc .requestAirdrop (owner .publicKey , 1e9 );
46-
47- const mintAuthority = Keypair .generate ();
48- const mintKeypair = Keypair .generate ();
49- const { mint } = await createMint (
50- rpc ,
51- payer ,
52- mintAuthority .publicKey ,
53- 9 ,
54- mintKeypair ,
55- );
56-
57- await mintTo (rpc , payer , mint , owner .publicKey , mintAuthority , bn (1000 ));
58-
59- // Get light-token ATA address
60- const tokenAta = getAssociatedTokenAddressInterface (mint , owner .publicKey );
61-
62- // Load compressed tokens to hot balance
63- // Creates ATA if needed, returns null if nothing to load
64- const signature = await loadAta (rpc , tokenAta , owner , mint , payer );
65-
66- if (signature ) {
67- console .log (" Loaded tokens to hot balance" );
68- console .log (" Transaction:" , signature );
69- } else {
70- console .log (" Nothing to load" );
71- }
72- }
73-
74- main ().catch (console .error );
75- ```
76-
77- ``` typescript Instruction
78- import { Keypair , ComputeBudgetProgram } from " @solana/web3.js" ;
79- import {
80- createRpc ,
81- bn ,
82- buildAndSignTx ,
83- sendAndConfirmTx ,
84- dedupeSigner ,
85- } from " @lightprotocol/stateless.js" ;
86- import {
87- createMint ,
88- mintTo ,
89- createLoadAtaInstructions ,
90- getAssociatedTokenAddressInterface ,
91- } from " @lightprotocol/compressed-token" ;
92-
93- async function main() {
94- const rpc = createRpc ();
95- const payer = Keypair .generate ();
96- await rpc .requestAirdrop (payer .publicKey , 10e9 );
97-
98- const owner = Keypair .generate ();
99- await rpc .requestAirdrop (owner .publicKey , 1e9 );
100-
101- const mintAuthority = Keypair .generate ();
102- const mintKeypair = Keypair .generate ();
103- const { mint } = await createMint (
104- rpc ,
105- payer ,
106- mintAuthority .publicKey ,
107- 9 ,
108- mintKeypair
109- );
110-
111- await mintTo (rpc , payer , mint , owner .publicKey , mintAuthority , bn (1000 ));
112-
113- // Get light-token ATA address
114- const tokenAta = getAssociatedTokenAddressInterface (mint , owner .publicKey );
115-
116- // Create load instructions
117- const ixs = await createLoadAtaInstructions (
118- rpc ,
119- tokenAta ,
120- owner .publicKey ,
121- mint ,
122- payer .publicKey
123- );
124-
125- if (ixs .length === 0 ) {
126- console .log (" Nothing to load" );
127- return ;
128- }
129-
130- // Build, sign, and send transaction
131- const { blockhash } = await rpc .getLatestBlockhash ();
132- const additionalSigners = dedupeSigner (payer , [owner ]);
133-
134- const tx = buildAndSignTx (
135- [ComputeBudgetProgram .setComputeUnitLimit ({ units: 500_000 }), ... ixs ],
136- payer ,
137- blockhash ,
138- additionalSigners
139- );
140-
141- const signature = await sendAndConfirmTx (rpc , tx );
142- console .log (" Loaded tokens to hot balance" );
143- console .log (" Transaction:" , signature );
144- }
28+ ### Warm up a cold market and trade
14529
146- main ().catch (console .error );
147- ```
30+ Prepend idempotent decompress instructions before your trade.
31+ ` loadAta ` returns null and ` createLoadAtaInstructions ` returns an empty array
32+ when the account is already hot, so this pattern is safe to use unconditionally.
14833
149- </CodeGroup >
34+ <Tabs >
35+ <Tab title = " Action" >
36+ <WarmUpAction />
37+ </Tab >
38+ <Tab title = " Instruction" >
39+ <WarmUpInstruction />
40+ </Tab >
41+ </Tabs >
15042
15143</Step >
15244</Steps >
15345
154- # Stream Light-Mint Accounts
46+ # Stream light-mint accounts
15547
15648<Card
15749 title = " Toolkit to stream light-mints"
15850 icon = " chevron-right"
15951 color = " #0066ff"
16052 href = " /light-token/toolkits/for-streaming-mints"
16153 horizontal
162- />
54+ />
0 commit comments