Skip to content

Commit 2f1478f

Browse files
tilo-14tilo-14claude
authored
Add Rust client examples to cookbook (#21)
* add rust client, programs, anchor * remove anchor macros, instruction decoder (moved to add-anchor-macros branch) * add overview * update rust client Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * add macro1 * fix animation compare * add compares * a1 * ai skill1 * status before anchor * update streaming * update otkens * update cookbook anchor examples * rm program * fix deps * fix dep * fix conflicts * update docs son * update setup * fix linter ci * fix linter ci --------- Co-authored-by: tilo-14 <tilo@luminouslabs.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b2e6f73 commit 2f1478f

82 files changed

Lines changed: 4000 additions & 3346 deletions

File tree

Some content is hidden

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

.mintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

.mintlifyignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

client-library/client-guide.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ Use the [API documentation](https://lightprotocol.github.io/light-protocol/) to
127127

128128
```bash
129129
npm install --save \
130-
@lightprotocol/stateless.js@beta \
131-
@lightprotocol/compressed-token@beta \
130+
@lightprotocol/stateless.js \
131+
@lightprotocol/compressed-token \
132132
@solana/web3.js
133133
```
134134

@@ -138,8 +138,8 @@ npm install --save \
138138

139139
```bash
140140
yarn add \
141-
@lightprotocol/stateless.js@beta \
142-
@lightprotocol/compressed-token@beta \
141+
@lightprotocol/stateless.js \
142+
@lightprotocol/compressed-token \
143143
@solana/web3.js
144144
```
145145

@@ -149,8 +149,8 @@ yarn add \
149149

150150
```bash
151151
pnpm add \
152-
@lightprotocol/stateless.js@beta \
153-
@lightprotocol/compressed-token@beta \
152+
@lightprotocol/stateless.js \
153+
@lightprotocol/compressed-token \
154154
@solana/web3.js
155155
```
156156

@@ -182,7 +182,7 @@ const rpc = createRpc('https://devnet.helius-rpc.com/?api-key=YOUR_API_KEY');
182182
1. Install the CLI
183183

184184
```bash
185-
npm i -g @lightprotocol/zk-compression-cli@beta
185+
npm i -g @lightprotocol/zk-compression-cli
186186
```
187187

188188
2. Start a local Solana test validator, photon indexer, and prover server on default ports 8899, 8784, and 3001.
@@ -253,7 +253,7 @@ client.payer = read_keypair_file("~/.config/solana/id.json")?;
253253
1. Install the CLI
254254

255255
```bash
256-
npm i -g @lightprotocol/zk-compression-cli@beta
256+
npm i -g @lightprotocol/zk-compression-cli
257257
```
258258

259259
2. Start a single-node Solana cluster, an RPC node, and a prover node at ports 8899, 8784, and 3001.

cspell.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@
192192
"offramps",
193193
"zkcompression",
194194
"Tasktool",
195-
"clippy"
195+
"clippy",
196+
"Raydium",
197+
"raydium"
196198
],
197199
"ignorePaths": [
198200
"node_modules",

docs.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,39 @@
5555
"pages": [
5656
"light-token/toolkits/overview",
5757
"light-token/toolkits/for-payments",
58-
"light-token/toolkits/for-wallets"
58+
"light-token/toolkits/for-wallets",
59+
"light-token/toolkits/for-streaming-mints",
60+
"light-token/toolkits/for-streaming-tokens"
5961
]
6062
},
6163
{
6264
"group": "Cookbook",
6365
"pages": [
6466
"light-token/cookbook/overview",
67+
{
68+
"group": "Examples",
69+
"expanded": true,
70+
"pages": [
71+
"light-token/examples/client"
72+
]
73+
},
6574
{
6675
"group": "Recipes",
76+
"expanded": true,
6777
"pages": [
6878
"light-token/cookbook/create-mint",
6979
"light-token/cookbook/create-ata",
7080
"light-token/cookbook/create-token-account",
7181
"light-token/cookbook/mint-to",
72-
"light-token/cookbook/close-token-account",
7382
"light-token/cookbook/transfer-interface",
83+
"light-token/cookbook/transfer-checked",
84+
"light-token/cookbook/approve-revoke",
85+
"light-token/cookbook/freeze-thaw",
7486
"light-token/cookbook/wrap-unwrap",
75-
"light-token/cookbook/load-ata"
87+
"light-token/cookbook/load-ata",
88+
"light-token/cookbook/close-token-account",
89+
"light-token/cookbook/burn"
90+
7691
]
7792
}
7893
]
@@ -254,7 +269,6 @@
254269
"references/whitepaper",
255270
"references/node-operators",
256271
"references/terminology",
257-
"references/light-token-terminology",
258272
"references/migration-v1-to-v2",
259273
"support",
260274
"references/security"

init-light.skill

1.66 KB
Binary file not shown.
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
title: Approve and Revoke Delegates
3+
sidebarTitle: Approve / Revoke
4+
description: Rust client guide to approve and revoke delegates for Light Token accounts. Includes step-by-step implementation and full code examples.
5+
keywords: ["approve delegate solana", "revoke delegate solana", "token delegation"]
6+
---
7+
8+
---
9+
10+
import TokenClientPrerequisites from "/snippets/light-token-guides/light-token-client-prerequisites.mdx";
11+
import FullSetup from "/snippets/setup/full-setup.mdx";
12+
import { CodeCompare } from "/snippets/jsx/code-compare.jsx";
13+
import {
14+
splApproveCode,
15+
lightApproveCode,
16+
splRevokeCode,
17+
lightRevokeCode,
18+
splApproveRustCode,
19+
lightApproveRustCode,
20+
splRevokeRustCode,
21+
lightRevokeRustCode,
22+
} from "/snippets/code-samples/code-compare-snippets.jsx";
23+
import TsApproveActionCode from "/snippets/code-snippets/light-token/approve-revoke/approve-action.mdx";
24+
import TsRevokeActionCode from "/snippets/code-snippets/light-token/approve-revoke/revoke-action.mdx";
25+
import ApproveActionCode from "/snippets/code-snippets/light-token/approve-revoke/rust-client/approve-action.mdx";
26+
import ApproveInstructionCode from "/snippets/code-snippets/light-token/approve-revoke/rust-client/approve-instruction.mdx";
27+
import RevokeActionCode from "/snippets/code-snippets/light-token/approve-revoke/rust-client/revoke-action.mdx";
28+
import RevokeInstructionCode from "/snippets/code-snippets/light-token/approve-revoke/rust-client/revoke-instruction.mdx";
29+
import ApproveAnchorProgramCode from "/snippets/code-snippets/light-token/approve/anchor-program/full-example.mdx";
30+
import RevokeAnchorProgramCode from "/snippets/code-snippets/light-token/revoke/anchor-program/full-example.mdx";
31+
32+
1. Approve grants a delegate permission to transfer up to a specified amount of tokens from your account.
33+
* Each token account can have only one delegate at a time.
34+
* Any new approval overwrites the previous one.
35+
2. Revoke removes all delegate permissions from a Light Token account.
36+
3. Only the token account owner can approve or revoke delegates.
37+
38+
<Tabs>
39+
40+
<Tab title="TypeScript Client">
41+
42+
<Tabs>
43+
<Tab title="Approve">
44+
45+
`approve` grants a delegate permission to transfer up to a specified amount of tokens.
46+
47+
<CodeCompare
48+
firstCode={lightApproveCode}
49+
secondCode={splApproveCode}
50+
firstLabel="light-token"
51+
secondLabel="SPL"
52+
/>
53+
54+
</Tab>
55+
<Tab title="Revoke">
56+
57+
`revoke` removes all delegate permissions from a Light Token account.
58+
59+
<CodeCompare
60+
firstCode={lightRevokeCode}
61+
secondCode={splRevokeCode}
62+
firstLabel="light-token"
63+
secondLabel="SPL"
64+
/>
65+
66+
</Tab>
67+
</Tabs>
68+
69+
<Info>
70+
Find the source code
71+
[here](https://github.com/Lightprotocol/examples-light-token/tree/main/typescript-client/actions).
72+
</Info>
73+
74+
<Steps>
75+
<Step>
76+
### Approve a delegate
77+
78+
<FullSetup />
79+
80+
<TsApproveActionCode />
81+
82+
</Step>
83+
84+
<Step>
85+
### Revoke a delegate
86+
87+
<TsRevokeActionCode />
88+
89+
</Step>
90+
</Steps>
91+
92+
</Tab>
93+
94+
<Tab title="Rust Client">
95+
96+
<Tabs>
97+
<Tab title="Approve">
98+
99+
<CodeCompare
100+
firstCode={lightApproveRustCode}
101+
secondCode={splApproveRustCode}
102+
firstLabel="light-token"
103+
secondLabel="SPL"
104+
language="rust"
105+
/>
106+
107+
</Tab>
108+
<Tab title="Revoke">
109+
110+
<CodeCompare
111+
firstCode={lightRevokeRustCode}
112+
secondCode={splRevokeRustCode}
113+
firstLabel="light-token"
114+
secondLabel="SPL"
115+
language="rust"
116+
/>
117+
118+
</Tab>
119+
</Tabs>
120+
121+
<Steps>
122+
<Step>
123+
### Prerequisites
124+
125+
<TokenClientPrerequisites />
126+
127+
</Step>
128+
129+
<Step>
130+
### Approve or revoke delegates
131+
132+
<Info>
133+
Find the full example including shared test utilities in the
134+
[examples-light-token](https://github.com/Lightprotocol/examples-light-token/tree/main/rust-client).
135+
</Info>
136+
137+
<Tabs>
138+
<Tab title="Approve">
139+
<Tabs>
140+
<Tab title="Action">
141+
<ApproveActionCode />
142+
</Tab>
143+
<Tab title="Instruction">
144+
<ApproveInstructionCode />
145+
</Tab>
146+
</Tabs>
147+
</Tab>
148+
<Tab title="Revoke">
149+
<Tabs>
150+
<Tab title="Action">
151+
<RevokeActionCode />
152+
</Tab>
153+
<Tab title="Instruction">
154+
<RevokeInstructionCode />
155+
</Tab>
156+
</Tabs>
157+
</Tab>
158+
</Tabs>
159+
160+
</Step>
161+
</Steps>
162+
</Tab>
163+
164+
</Tabs>
165+
166+
# Next Steps
167+
168+
<Card
169+
title="Go back to the overview for the Light Token standard"
170+
icon="chevron-right"
171+
color="#0066ff"
172+
href="/light-token/welcome"
173+
horizontal
174+
/>

light-token/cookbook/burn.mdx

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: Burn Light Tokens
3+
sidebarTitle: Burn
4+
description: Rust client guide to burn Light Tokens. Includes step-by-step implementation and full code examples.
5+
keywords: ["burn tokens on solana", "destroy tokens solana", "reduce token supply"]
6+
---
7+
8+
---
9+
10+
import TokenClientPrerequisites from "/snippets/light-token-guides/light-token-client-prerequisites.mdx";
11+
import { CodeCompare } from "/snippets/jsx/code-compare.jsx";
12+
import {
13+
splBurnRustCode,
14+
lightBurnRustCode,
15+
} from "/snippets/code-samples/code-compare-snippets.jsx";
16+
import RustInstructionCode from "/snippets/code-snippets/light-token/burn/rust-client/instruction.mdx";
17+
import BurnCheckedRustInstructionCode from "/snippets/code-snippets/light-token/burn-checked/rust-client/instruction.mdx";
18+
19+
20+
21+
1. Burn permanently destroys tokens by reducing the balance in a token account.
22+
2. Burned tokens are removed from circulation and decreases the supply tracked on the mint account.
23+
3. Only the token account owner (or approved delegate) can burn tokens.
24+
25+
<Tabs>
26+
<Tab title="Rust Client">
27+
28+
Compare to SPL:
29+
30+
<CodeCompare
31+
firstCode={lightBurnRustCode}
32+
secondCode={splBurnRustCode}
33+
firstLabel="light-token"
34+
secondLabel="SPL"
35+
language="rust"
36+
/>
37+
38+
<Steps>
39+
<Step>
40+
### Prerequisites
41+
42+
<TokenClientPrerequisites />
43+
44+
</Step>
45+
46+
<Step>
47+
### Burn Light Tokens
48+
49+
<Info>
50+
Find the full example including shared test utilities in the
51+
[examples-light-token](https://github.com/Lightprotocol/examples-light-token/tree/main/rust-client).
52+
</Info>
53+
54+
<Tabs>
55+
<Tab title="Instruction">
56+
<RustInstructionCode />
57+
</Tab>
58+
</Tabs>
59+
</Step>
60+
</Steps>
61+
</Tab>
62+
63+
</Tabs>
64+
65+
# Next Steps
66+
67+
<Card
68+
title="Learn to freeze and thaw Light Token accounts"
69+
icon="chevron-right"
70+
color="#0066ff"
71+
href="/light-token/cookbook/freeze-thaw"
72+
horizontal
73+
/>

0 commit comments

Comments
 (0)