Skip to content

Commit 0d2001d

Browse files
author
tilo-14
committed
docs: add program examples README
1 parent e917f4b commit 0d2001d

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

program-examples/README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Light Token Program Examples
2+
3+
Native Solana program examples that CPI the Light Token Program.
4+
5+
### Native
6+
7+
- **create-mint** - Create a light-token mint via CPI
8+
- [Instruction](native/program/src/instructions/create_mint.rs) | [Test](native/program/tests/create_mint.rs)
9+
- **create-ata** - Create an associated light-token account via CPI
10+
- [Instruction](native/program/src/instructions/create_ata.rs) | [Test](native/program/tests/create_ata.rs)
11+
- **mint-to** - Mint tokens via CPI
12+
- [Instruction](native/program/src/instructions/mint_to.rs) | [Test](native/program/tests/mint_to.rs)
13+
- **transfer-interface** - Transfer between light-token, T22, and SPL accounts via CPI
14+
- [Instruction](native/program/src/instructions/transfer_interface.rs) | [Test](native/program/tests/transfer.rs)
15+
- **approve** - Approve delegate via CPI
16+
- [Instruction](native/program/src/instructions/approve.rs) | [Test](native/program/tests/approve.rs)
17+
- **revoke** - Revoke delegate via CPI
18+
- [Instruction](native/program/src/instructions/revoke.rs) | [Test](native/program/tests/revoke.rs)
19+
- **burn** - Burn tokens via CPI
20+
- [Instruction](native/program/src/instructions/burn.rs) | [Test](native/program/tests/burn.rs)
21+
- **freeze** - Freeze token account via CPI
22+
- [Instruction](native/program/src/instructions/freeze.rs) | [Test](native/program/tests/freeze.rs)
23+
- **thaw** - Thaw token account via CPI
24+
- [Instruction](native/program/src/instructions/thaw.rs) | [Test](native/program/tests/thaw.rs)
25+
- **close** - Close token account via CPI
26+
- [Instruction](native/program/src/instructions/close.rs) | [Test](native/program/tests/close.rs)
27+
28+
## Build
29+
30+
```bash
31+
cargo build-sbf
32+
```
33+
34+
## Test
35+
36+
### Requirements
37+
38+
- light cli version 0.24.0+ (install via `npm i -g @lightprotocol/zk-compression-cli`)
39+
- solana cli version 2.1.16+
40+
- Node.js and npm
41+
42+
### Rust Tests
43+
44+
```bash
45+
cargo test-sbf
46+
```
47+
48+
### TypeScript Tests
49+
50+
1. Build the program:
51+
52+
```bash
53+
cargo build-sbf
54+
```
55+
56+
2. Start the test validator:
57+
58+
```bash
59+
light test-validator --sbf-program "TokenCpi11111111111111111111111111111111111" ./native/target/deploy/light_token_ops.so
60+
```
61+
62+
3. Install dependencies and run tests:
63+
64+
```bash
65+
cd native
66+
npm install
67+
npm test
68+
```
69+
70+
`light test-validator` spawns the following background processes:
71+
72+
1. solana test validator `http://127.0.0.1:8899`
73+
2. prover server `http://127.0.0.1:3001`
74+
3. photon indexer `http://127.0.0.1:8784`
75+
76+
You can kill these background processes with `lsof -i:<port>` and `kill <pid>`.
77+
78+
## Documentation
79+
80+
Learn more [about Light-Token here](https://www.zkcompression.com/light-token/welcome).

0 commit comments

Comments
 (0)