From cc595aeee1173fe96e9f451190b4209e2351a574 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Tue, 3 Feb 2026 18:01:24 +0000 Subject: [PATCH 01/27] before restr home --- compressed-tokens/advanced-guides/airdrop.mdx | 4 +- welcome.mdx | 100 +----------------- 2 files changed, 3 insertions(+), 101 deletions(-) diff --git a/compressed-tokens/advanced-guides/airdrop.mdx b/compressed-tokens/advanced-guides/airdrop.mdx index ce18f3ef..78a88f13 100644 --- a/compressed-tokens/advanced-guides/airdrop.mdx +++ b/compressed-tokens/advanced-guides/airdrop.mdx @@ -1,6 +1,6 @@ --- -title: Airdrop Guide with ZK Compression -sidebarTitle: Airdrop Guide +title: Airdrop Guide +sidebarTitle: For Airdrops description: Complete client and program guides to create an airdrop – with or without code. ZK compression is the most efficient way to distribute SPL tokens. keywords: ["solana airdrop", "merkle distributor", "merkle airdrop", "airdrop infrastructure on solana", "scalable token distribution on solana", "token airdrop for protocols"] --- diff --git a/welcome.mdx b/welcome.mdx index 16f17ef4..b68b8adb 100644 --- a/welcome.mdx +++ b/welcome.mdx @@ -9,51 +9,6 @@ import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx"; ![](/images/banner-image.png) -| **Creation Cost** | Solana | ZK Compression | -| :---------------- | :------------------ | :------------------- | -| **Token Account** | ~2,000,000 lamports | ~**5,000** lamports | -| **100-byte PDA** | ~1,600,000 lamports | ~**15,000** lamports | - -## Features - - - High performance token standard for rent-free DeFi and Payments. - - - - - - For App State. - - - For Token Distribution. - - - -## Quickstart - - - - - - - - - - ## What is ZK Compression? ZK Compression is a framework that reduces the storage cost of Solana accounts by combining generalized state compression and zero-knowledge proofs. @@ -68,57 +23,4 @@ ZK Compression is a framework that reduces the storage cost of Solana accounts b the compressed accounts. By default, this is all done under the hood. You can fetch validity proofs from RPC providers that support ZK Compression. - - -## Resources - - - - Browse ZK Compression's JSON RPC methods. - - - Explore our TypeScript and Rust SDKs. - - - Install the ZK Compression CLI for local development. - - - -## Learn & Community - - - - Learn about ZK Compression's core concepts. - - - Read our external audit and formal verification reports. - - - Join our Discord for support and discussions. - - - -## Next Steps - - + \ No newline at end of file From 570c65b83fae7944fcc2f24dd9264b62867f29c7 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Tue, 3 Feb 2026 21:45:09 +0000 Subject: [PATCH 02/27] home first draft --- home.mdx | 271 +++++++++---------------------- light-token/welcome.mdx | 8 - resources/addresses-and-urls.mdx | 5 +- 3 files changed, 83 insertions(+), 201 deletions(-) diff --git a/home.mdx b/home.mdx index 664e469e..d2ae9c5a 100644 --- a/home.mdx +++ b/home.mdx @@ -7,7 +7,6 @@ keywords: ["light protocol", "zk compression on solana", "scalable solana infras import { Footer } from "/snippets/jsx/footer.jsx"; import { HeroCubeGrid } from "/snippets/jsx/hero-cube-grid.jsx"; import { LiquidGlassPill } from "/snippets/jsx/liquid-glass-pill.jsx"; -import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx"; {/* Hero with animation - styles in style.css (no flash) */} @@ -20,15 +19,6 @@ import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx";
- - - High performance token standard for rent-free DeFi and Payments. - - - Core primitives for rent-free tokens & accounts. - - - ## Features @@ -37,193 +27,92 @@ import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx"; Works with existing programs and accounts. -## Quickstart - - - -### Installation +## Light Token - - - -### Get started - - - - +High-performance token standard for rent-free DeFi and Payments. + + Introduction to the Light Token program. + + + + Guides for mints, token accounts, and transfers. + + + TypeScript and Rust client examples. + + + Anchor program examples. + + -## DeFi Integration +### DeFi - Build rent-free AMMs and DeFi programs with minimal code changes. + Build rent-free AMMs and DeFi programs. - Add support for rent-free AMMs to your aggregator or router. + Add support for rent-free AMMs to your aggregator. -## Toolkits +### Toolkits - - - - Integrate light-token APIs with familiar SPL patterns. - - - - Allow users to display and swap light-tokens. - - - {/* - Stream mint events from the network in real-time. - */} - - {/* - Stream token events from the network in real-time. - */} - - - - - ZK Compression is the most efficient way to distribute SPL tokens. - - - Add rent-free SPL token accounts and transfers to your Privy embedded wallet. - - - Allow users to display and swap compressed tokens. - - - - Integrate Token-2022 extensions with compressed tokens. - - - - Common token distribution flows (airdrops, payments, rewards). - - - - - - Deterministically derived addresses to prevent double spending. - - - - Small proof size and fast verification. - - - - Use existing state Merkle trees with RPC indexer support. - - - - + + + Integrate light-token APIs with familiar SPL patterns. + + + Display and swap light-tokens. + + + Stream mint events from the network in real-time. + + + Index and stream token events. + + + Efficient token distribution at scale. + + + Add rent-free tokens to Privy embedded wallets. + + -## Cookbooks +## Compressed PDAs - - - Program and client guides for mints, token accounts, and transfers. +Rent-free PDA accounts for on-chain programs. + + + Introduction to compressed PDAs. - - Client guides for compressed token accounts. + + + Build clients for compressed accounts. - - Program and client guides for rent-free PDA accounts. + + Create, update, and close compressed accounts. - - Build with compressed attestations using Rust or Typescript. + + Example programs using compressed PDAs. -## Using AI in Development +### Toolkits + + + + System for payments and AI agents to prevent your onchain instruction from being executed more than once. + + + How to build a ZK program on Solana with nullifiers, groth-16 proofs and merklelized state. + + + Credential system for KYC verification, professional badges, and compliance credentials in minutes. + + + +## AI Tools Download agent skill or view [skill.md](https://www.zkcompression.com/skill.md): ```bash @@ -279,19 +168,18 @@ codex mcp add deepwiki -- npx -y mcp-remote@latest https://mcp.deepwiki.com/mcp ## Resources - - - View security audits and formal verification. + + + Learn core concepts of the Light token program and ZK Compression Core. + + + Debug common errors and issues. - - Learn core concepts of the Light token program. + + RPC endpoints and addresses for programs, Merkle trees, and other accounts. - - Learn core concepts of ZK Compression. + + View security audits and formal verification. @@ -318,7 +206,10 @@ codex mcp add deepwiki -- npx -y mcp-remote@latest https://mcp.deepwiki.com/mcp ### Rust - + + + Light Token program SDK. + Rust client for Light Token and ZK Compression. diff --git a/light-token/welcome.mdx b/light-token/welcome.mdx index a2bbc397..cef11232 100644 --- a/light-token/welcome.mdx +++ b/light-token/welcome.mdx @@ -65,14 +65,6 @@ import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx"; ### Get Started - - diff --git a/resources/addresses-and-urls.mdx b/resources/addresses-and-urls.mdx index c7f3308e..e71c08bb 100644 --- a/resources/addresses-and-urls.mdx +++ b/resources/addresses-and-urls.mdx @@ -174,13 +174,12 @@ main(); # Next Steps -Start building with Compressed Tokens or PDAs Date: Tue, 3 Feb 2026 22:13:43 +0000 Subject: [PATCH 03/27] compressed pdas --- client-library/client-guide.mdx | 2 - compressed-pdas/overview.mdx | 9 +++ home.mdx | 43 +------------- light-token/welcome.mdx | 10 ++++ .../compressed-pdas-guides-table.mdx | 57 ++++++++++++++++--- .../overview-tables/examples-guides-table.mdx | 26 +++++++++ .../program-examples-table.mdx | 9 ++- .../sdk-reference-compressed-pdas.mdx | 32 +++++++++++ snippets/overview-tables/sdk-reference.mdx | 45 +++++++++++++++ zk/overview.mdx | 4 +- 10 files changed, 183 insertions(+), 54 deletions(-) create mode 100644 snippets/overview-tables/examples-guides-table.mdx create mode 100644 snippets/overview-tables/sdk-reference-compressed-pdas.mdx create mode 100644 snippets/overview-tables/sdk-reference.mdx diff --git a/client-library/client-guide.mdx b/client-library/client-guide.mdx index deb82b16..4be83bc8 100644 --- a/client-library/client-guide.mdx +++ b/client-library/client-guide.mdx @@ -10,8 +10,6 @@ import SystemAccountsList from '/snippets/accounts-list/compressed-pdas-system-a import TypescriptClient from '/snippets/code-snippets/create/typescript-client.mdx'; import RustClient from '/snippets/code-snippets/create/rust-client.mdx'; -ZK Compression provides Rust and Typescript clients to interact with compressed accounts and tokens on Solana. - diff --git a/compressed-pdas/overview.mdx b/compressed-pdas/overview.mdx index 75c410a7..258816e0 100644 --- a/compressed-pdas/overview.mdx +++ b/compressed-pdas/overview.mdx @@ -6,6 +6,8 @@ keywords: ["rent free program derived addresses", "rent free pda accounts", "com import ProgramExamplesTable from '/snippets/overview-tables/program-examples-table.mdx'; import DevelopmentEnvironmentSetup from '/snippets/setup/development-environment-setup.mdx'; +import CompressedPdasGuidesTable from '/snippets/overview-tables/compressed-pdas-guides-table.mdx'; +import SdkReferenceCompressedPdas from '/snippets/overview-tables/sdk-reference-compressed-pdas.mdx'; | Creation | Regular PDA Account | Compressed PDA | @@ -174,10 +176,17 @@ Caused by: +## Guides + + + ## Program Examples +## SDK Reference + + # Next Steps diff --git a/home.mdx b/home.mdx index d2ae9c5a..671d38ad 100644 --- a/home.mdx +++ b/home.mdx @@ -1,12 +1,13 @@ --- title: "Home" mode: "custom" -keywords: ["light protocol", "zk compression on solana", "scalable solana infrastructure", "rent free accounts on solana", "create tokens on solana", "scalable infrastructure for solana apps", "privacy on solana", "shielded transactions on solana"] +keywords: ["solana tokens", "spl tokens", "light protocol", "helius", "zk compression on solana", "scalable solana infrastructure", "rent free accounts on solana", "create tokens on solana", "scalable infrastructure for solana apps", "privacy on solana", "shielded transactions on solana"] --- import { Footer } from "/snippets/jsx/footer.jsx"; import { HeroCubeGrid } from "/snippets/jsx/hero-cube-grid.jsx"; import { LiquidGlassPill } from "/snippets/jsx/liquid-glass-pill.jsx"; +import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; {/* Hero with animation - styles in style.css (no flash) */} @@ -185,45 +186,7 @@ codex mcp add deepwiki -- npx -y mcp-remote@latest https://mcp.deepwiki.com/mcp ## SDK Reference -### TypeScript - - - - Client SDK for Light Token and Compressed Accounts - - - Client for Light Token and Compressed Tokens. - - - -### Rust - - - - Light Token program SDK. - - - Rust client for Light Token and ZK Compression. - - - Core SDK for on-chain programs. - - - Testing framework for programs. - - + diff --git a/light-token/welcome.mdx b/light-token/welcome.mdx index cef11232..bb9eb1bb 100644 --- a/light-token/welcome.mdx +++ b/light-token/welcome.mdx @@ -16,7 +16,9 @@ import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx import CompressibleDefaultRentConfig from "/snippets/compressible-default-rent-config.mdx"; import IntegrateLightTokenGuidesTable from "/snippets/overview-tables/integrate-light-token-guides-table.mdx"; import CookbookGuidesTable from "/snippets/overview-tables/cookbook-guides-table.mdx"; +import ExamplesGuidesTable from "/snippets/overview-tables/examples-guides-table.mdx"; import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx"; +import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; **Note: This page is for the new Light Token Program Beta.** For production use today, use @@ -87,6 +89,14 @@ import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx"; +## Examples + + + +## SDK Reference + + + # Next Steps + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Create + Initialize compressed PDAs in your program
+ Update + Modify state in compressed accounts
+ Close + Reclaim lamports from compressed accounts
+ Reinitialize + Reset and reuse compressed accounts
+ Burn + Permanently delete compressed accounts
+ Nullifier PDAs + Prevent replay attacks with one-time use accounts
diff --git a/snippets/overview-tables/examples-guides-table.mdx b/snippets/overview-tables/examples-guides-table.mdx new file mode 100644 index 00000000..d0d9dbb3 --- /dev/null +++ b/snippets/overview-tables/examples-guides-table.mdx @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + +
+ Client + TypeScript and Rust client examples for light-token SDK
+ Program + Anchor program examples for light-token CPI, Macros and more
\ No newline at end of file diff --git a/snippets/overview-tables/program-examples-table.mdx b/snippets/overview-tables/program-examples-table.mdx index 86761063..3a52e419 100644 --- a/snippets/overview-tables/program-examples-table.mdx +++ b/snippets/overview-tables/program-examples-table.mdx @@ -1,12 +1,15 @@ | Example | Description | |:---------|:------------| +| [Account Comparison](https://github.com/Lightprotocol/program-examples/tree/main/account-comparison) | Compare compressed accounts with standard Solana accounts | | [basic-operations/anchor](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor) | Anchor programs to create, update, close, reinitialize and burn compressed accounts with Rust and TypeScript tests | | [basic-operations/native](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native) | Native Solana program implementation to create, update, close, reinitialize and burn compressed accounts with Rust tests | | [Counter (Anchor)](https://github.com/Lightprotocol/program-examples/tree/main/counter/anchor) | Full compressed account lifecycle (create, increment, decrement, reset, close) using Anchor framework | | [Counter (Native)](https://github.com/Lightprotocol/program-examples/tree/main/counter/native) | Native Solana program implementation with Rust tests | | [Counter (Pinocchio)](https://github.com/Lightprotocol/program-examples/tree/main/counter/pinocchio) | Pinocchio implementation using light-sdk-pinocchio with Rust tests | | [Create-and-Update](https://github.com/Lightprotocol/program-examples/tree/main/create-and-update) | Create new compressed accounts and update existing ones within a single instruction and one validity proof | +| [merkle-distributor](https://github.com/Lightprotocol/distributor) | SPL token distribution with compressed PDAs for claim tracking, vesting, and clawback | +| [Nullifier Program](https://github.com/Lightprotocol/nullifier-program) | System for payments and AI agents to prevent your onchain instruction from being executed more than once | | [Read-Only](https://github.com/Lightprotocol/program-examples/tree/main/read-only) | Create compressed accounts and read them on-chain | -| [Account Comparison](https://github.com/Lightprotocol/program-examples/tree/main/account-comparison) | Compare compressed accounts with standard Solana accounts | -| [Nullifier Program](https://github.com/Lightprotocol/nullifier-program) | For some use cases, such as sending payments, you might want to prevent your onchain instruction from being executed more than once. Creates a rent-free PDA derived from an id. If the id has been used before, the PDA already exists, causing the instruction to fail | -| [ZK-ID](https://github.com/Lightprotocol/program-examples/tree/main/zk-id) | Program that uses zero-knowledge proofs for identity verification with compressed accounts | +| [simple-claim](https://github.com/Lightprotocol/program-examples-airdrop-implementations/tree/main/simple-claim) | Distributes compressed tokens that decompress to SPL on claim | +| [ZK-ID](https://github.com/Lightprotocol/program-examples/tree/main/zk-id) | Zero-knowledge proofs for identity verification with compressed accounts | +| [ZK-Nullifier](https://github.com/Lightprotocol/program-examples/tree/main/zk-nullifier) | Implementation of nullifiers for zk programs on Solana to prevent double spending | diff --git a/snippets/overview-tables/sdk-reference-compressed-pdas.mdx b/snippets/overview-tables/sdk-reference-compressed-pdas.mdx new file mode 100644 index 00000000..99739874 --- /dev/null +++ b/snippets/overview-tables/sdk-reference-compressed-pdas.mdx @@ -0,0 +1,32 @@ +### Client + + + + TypeScript RPC client for compressed accounts, validity proofs, and address derivation. + + + Rust RPC client and indexer for compressed accounts. + + + +### Program + + + + Core SDK for compressed accounts in Anchor programs. + + + Procedural macros for LightAccount derivation. + + + Local testing framework for programs. + + diff --git a/snippets/overview-tables/sdk-reference.mdx b/snippets/overview-tables/sdk-reference.mdx new file mode 100644 index 00000000..ced6b237 --- /dev/null +++ b/snippets/overview-tables/sdk-reference.mdx @@ -0,0 +1,45 @@ +### Client SDKs + + + + TypeScript RPC client for Light Token and Compressed Accounts. + + + Rust RPC client for Light Token and ZK Compression. + + + TypeScript token operations for Light Token and Compressed Tokens. + + + Rust token operations for Light Token. + + + +### Program + + + + Core SDK for on-chain programs. + + + Procedural macros for Light accounts. + + + CPI instructions for Light Token program. + + + Local testing framework for programs. + + diff --git a/zk/overview.mdx b/zk/overview.mdx index c56e4714..781e76dd 100644 --- a/zk/overview.mdx +++ b/zk/overview.mdx @@ -16,11 +16,11 @@ Building a ZK Solana program requires: 4. An indexer to serve Merkle proofs 5. Encrypted state -## Nullifiers on Solana +## Nullifiers for ZK on Solana A nullifier is a deterministically derived hash to ensure an action can only be performed once. The nullifier cannot be linked to the action or user. -For example Zcash uses nullifiers to prevent double spending. +For example Zcash uses nullifiers to prevent double spending. To implement nullifiers we need a data structure that ensures every nullifier is only created once and never deleted. On Solana a straight forward way to implement nullifiers is to create a PDA account with the nullifier as seed. From a701f9caba074d4c8fa192c52a7eb1481464e390 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Tue, 10 Feb 2026 23:20:07 +0000 Subject: [PATCH 04/27] before rebase --- api-reference/sdk.mdx | 8 ++ compressed-pdas/overview.mdx | 83 ++++++++++++++++----- compressed-pdas/program-examples.mdx | 67 ++++++++--------- home.mdx | 106 +++++++++++++++------------ learn/overview.mdx | 55 ++++++++++++++ snippets/jsx/partner-logos.jsx | 24 ++++++ 6 files changed, 247 insertions(+), 96 deletions(-) create mode 100644 api-reference/sdk.mdx create mode 100644 learn/overview.mdx create mode 100644 snippets/jsx/partner-logos.jsx diff --git a/api-reference/sdk.mdx b/api-reference/sdk.mdx new file mode 100644 index 00000000..488d0888 --- /dev/null +++ b/api-reference/sdk.mdx @@ -0,0 +1,8 @@ +--- +title: SDK Reference +description: Client and program SDKs for Light Token and ZK Compression. +--- + +import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; + + \ No newline at end of file diff --git a/compressed-pdas/overview.mdx b/compressed-pdas/overview.mdx index 258816e0..a0ea81cd 100644 --- a/compressed-pdas/overview.mdx +++ b/compressed-pdas/overview.mdx @@ -1,6 +1,6 @@ --- title: Overview & Program Template -description: Compressed PDAs provide full functionality of accounts at PDAs, without rent-exemption per account. +description: Compressed PDAs provide full composability and functionality of accounts at PDAs, without rent-exemption per account. keywords: ["rent free program derived addresses", "rent free pda accounts", "compressed pda on solana", "infrastructure for depins on solana", "scalable solana infrastructure", "stake accounts for depins", "cost efficient stake accounts", "scalable reward distribution on solana"] --- @@ -16,23 +16,70 @@ import SdkReferenceCompressedPdas from '/snippets/overview-tables/sdk-reference- Compressed PDAs are derived using a specific program address and seed, like regular PDAs. Custom programs invoke the Light System program to create and update accounts, instead of the System program. -#### Compressed PDAs at a Glance - - - - Create accounts at program-derived addresses without upfront rent exempt balance. - - - Persistent unique identification and program ownership. - - - CPI support between compressed and regular PDAs. - - - -# Start Building - -Developing with compressed PDAs works similar to regular PDAs and involves minimal setup: + + +
+ + ![](/images/Untitled.png) + +
+
+ + ![](/images/image-22.png) + +
+
+ +
+ + ![](/images/Untitled-1.png) + +
+
+ + ![](/images/image-20.png) + +
+
+ +
+ + ![](/images/Untitled-4.png) + +
+
+ + ![](/images/image-23.png) + +
+
+ +
+ + ![](/images/program-reinit-1.png) + +
+
+ + ![](/images/program-reinit.png) + +
+
+ +
+ + ![](/images/program-burn-1.png) + +
+
+ + ![](/images/program-burn.png) + +
+
+
+ +# Start Building with the Program Template diff --git a/compressed-pdas/program-examples.mdx b/compressed-pdas/program-examples.mdx index 7e14d3d8..7bdf37fc 100644 --- a/compressed-pdas/program-examples.mdx +++ b/compressed-pdas/program-examples.mdx @@ -3,62 +3,63 @@ title: Program Examples description: Program example repository for compressed accounts with tests. --- -## Basic Operations +## Airdrop claim reference implementations -* [**basic-operations/anchor**](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor) - Anchor program with Rust and TypeScript tests -* [**basic-operations/native**](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native) - Native Solana program with `light-sdk` and Rust tests. +- **Basic**: [**simple-claim**](https://github.com/Lightprotocol/program-examples/tree/main/airdrop-implementations/simple-claim) - Distributes compressed tokens that get decompressed to SPL on claim with cliff. +- **Advanced**: [**merkle-distributor**](https://github.com/Lightprotocol/program-examples/tree/main/airdrop-implementations/distributor) - Distributes SPL tokens, uses compressed PDAs to track claims with linear vesting, partial claims and clawback. Based on Jito Merkle distributor and optimized with rent-free PDAs. -Basic Operations include: -- **create** - Initialize a new compressed account -- **update** - Modify data of an existing compressed account -- **close** - Close a compressed account (it can be initialized again). -- **reinit** - Reinitialize a closed account -- **burn** - Permanently delete a compressed account (it cannot be initialized again). +For simple client-side distribution visit [this example](https://github.com/Lightprotocol/example-token-distribution). -## Counter Program - -Full compressed account lifecycle (create, increment, decrement, reset, close): +## Basic operations -* [**counter/anchor**](https://github.com/Lightprotocol/program-examples/tree/main/counter/anchor) - Anchor program with Rust and TypeScript tests -* [**counter/native**](https://github.com/Lightprotocol/program-examples/tree/main/counter/native) - Native Solana program with `light-sdk` and Rust tests. -* [**counter/pinocchio**](https://github.com/Lightprotocol/program-examples/tree/main/counter/pinocchio) - Pinocchio program with `light-sdk-pinocchio` and Rust tests. +- **create** - Initialize a new compressed account + - [Anchor](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/create) | [Native](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/create) +- **update** - Modify data in an existing compressed account + - [Anchor](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/update) | [Native](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/update) +- **close** - Clear account data and preserve its address + - [Anchor](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/close) | [Native](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/close) +- **reinit** - Reinitialize a closed account with the same address + - [Anchor](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/reinit) | [Native](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/reinit) +- **burn** - Permanently delete a compressed account + - [Anchor](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/burn) | [Native](https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/burn) -## Create-and-update Program +## Nullifier program -* [**create-and-update**](https://github.com/Lightprotocol/program-examples/tree/main/create-and-update) - Create a new compressed account and update an existing compressed account with a single validity proof in one instruction. +[**nullifier-program**](https://github.com/Lightprotocol/nullifier-program) - For some use cases, such as sending payments, you might want to prevent your onchain instruction from being executed more than once. Creates a rent-free PDA derived from an id. If the id has been used before, the PDA already exists, causing the instruction to fail. -## Create-and-read Program +SDK: [`light-nullifier-program`](https://docs.rs/light-nullifier-program) | [Example client usage](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/actions/create_nullifier.rs) -* [**read-only**](https://github.com/Lightprotocol/program-examples/tree/main/read-only) - Create a new compressed account and read it on-chain. +## Counter program -## Compare Programs with Solana and Compressed Accounts +Full compressed account lifecycle (create, increment, decrement, reset, close): -* [**account-comparison**](https://github.com/Lightprotocol/program-examples/tree/main/account-comparison) - Compare compressed vs regular Solana accounts. +- [**counter/anchor**](https://github.com/Lightprotocol/program-examples/tree/main/counter/anchor) - Anchor program with Rust and TypeScript tests +- [**counter/native**](https://github.com/Lightprotocol/program-examples/tree/main/counter/native) - Native Solana program with `light-sdk` and Rust tests +- [**counter/pinocchio**](https://github.com/Lightprotocol/program-examples/tree/main/counter/pinocchio) - Pinocchio program with `light-sdk-pinocchio` and Rust tests -## Nullifier Program +## Create-and-update program -* [**nullifier-program**](https://github.com/Lightprotocol/nullifier-program) - For some use cases, such as sending payments, you might want to prevent your onchain instruction from being executed more than once. Creates a rent-free PDA derived from an id. If the id has been used before, the PDA already exists, causing the instruction to fail. +[**create-and-update**](https://github.com/Lightprotocol/program-examples/tree/main/create-and-update) - Create a new compressed account and update an existing compressed account with a single validity proof in one instruction. -## Token Claim Reference Implementations +## Create-and-read program -* **Basic**: [**simple-claim**](https://github.com/Lightprotocol/program-examples-airdrop-implementations/simple-claim) - Distributes compressed tokens that get decompressed to SPL on claim. -* **Advanced**: [**merkle-distributor**](https://github.com/Lightprotocol/distributor) - Distributes SPL tokens, uses compressed PDAs to track claims with linear vesting, partial claims, clawback and admin controls. +[**read-only**](https://github.com/Lightprotocol/program-examples/tree/main/read-only) - Create a new compressed account and read it onchain. - -For simple client side distribution visit [this example](https://github.com/Lightprotocol/example-token-distribution). - +## Compare program with Solana vs compressed accounts -## ZK-ID Program +[**account-comparison**](https://github.com/Lightprotocol/program-examples/tree/main/account-comparison) - Compare compressed vs regular Solana accounts. -* [**zk-id**](https://github.com/Lightprotocol/program-examples/tree/main/zk-id) - A minimal Solana program that uses zero-knowledge proofs for identity verification with compressed accounts. +## ZK programs +- [**zk-id**](https://github.com/Lightprotocol/program-examples/tree/main/zk/zk-id) - Identity verification using Groth16 proofs. Issuers create credentials; users prove ownership without revealing the credential. +- [**nullifier**](https://github.com/Lightprotocol/program-examples/tree/main/zk/nullifier) - Simple program to create nullifiers for ZK programs. -# Next Steps +## Next steps - + + +
{/* Content container - using Tailwind classes to avoid flash */} @@ -30,21 +33,12 @@ import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; ## Light Token -High-performance token standard for rent-free DeFi and Payments. +High-performance token standard that reduces the cost of mint and token accounts by 200x +while being more CU efficient than SPL on hot paths. + Introduction to the Light Token program. - - - Guides for mints, token accounts, and transfers. - - - TypeScript and Rust client examples. - - - Anchor program examples. - - ### DeFi @@ -55,67 +49,89 @@ High-performance token standard for rent-free DeFi and Payments. Add support for rent-free AMMs to your aggregator. + + High-performance DeFi programs with Pinocchio. + -### Toolkits +### Payments - - - Integrate light-token APIs with familiar SPL patterns. - - - Display and swap light-tokens. - - - Stream mint events from the network in real-time. + + + Guide to integrate light-token APIs with comparison to SPL. - - Index and stream token events. + + Prevent onchain instructions from being executed more than once. - - Efficient token distribution at scale. + + +### Wallets + + + + Guide for Wallet Applications to let users display and swap light-tokens. - + Add rent-free tokens to Privy embedded wallets. -## Compressed PDAs - -Rent-free PDA accounts for on-chain programs. +### Data Streaming - - Introduction to compressed PDAs. + + + Stream mint events from the network in real-time. + + + Stream token events from the network in real-time. + + +### Guides and Examples + - - Build clients for compressed accounts. + + Guides for mints, token accounts, and transfers. - - Create, update, and close compressed accounts. + + TypeScript and Rust client examples. - - Example programs using compressed PDAs. + + Anchor program examples. -### Toolkits - - - System for payments and AI agents to prevent your onchain instruction from being executed more than once. +## Token Distribution + + + + + Distribute tokens on Solana 5000x cheaper. - - How to build a ZK program on Solana with nullifiers, groth-16 proofs and merklelized state. + + Merkle distributor and simple claim programs for airdrops with claim. + + +## Compressed PDA Toolkits + + + To store app and user state without rent-exemption. Introduction to compressed PDAs. + + Credential system for KYC verification, professional badges, and compliance credentials in minutes. + + Build ZK programs on Solana with groth-16 proofs and merklelized state. + ## AI Tools Download agent skill or view [skill.md](https://www.zkcompression.com/skill.md): + ```bash npx skills add https://zkcompression.com ``` diff --git a/learn/overview.mdx b/learn/overview.mdx new file mode 100644 index 00000000..baebc649 --- /dev/null +++ b/learn/overview.mdx @@ -0,0 +1,55 @@ +--- +title: Overview to Core Concepts +sidebarTitle: Overview +description: Learn about Light Token and ZK Compression Core. +keywords: ["zk compression on solana", "scalable solana infrastructure", "compressed accounts on solana", "privacy on solana", "zk on solana", "shielded transactions on solana"] +--- + + +## What is Light Token? + +Light token is a high-performance token standard that is functionally equivalent to SPL, but stores mint and token accounts more efficiently. This reduces account creation cost while being more CU efficient than SPL on hot paths. + + + + + + + + +## What is ZK Compression? + +ZK Compression is a Solana account primitive that lets you create tokens and PDAs without rent-exemption with L1 performance and security. +The Light Token Program uses ZK Compression under the hood. + +Storage cost of Solana accounts are reduced by combining generalized state compression and zero-knowledge proofs. + + + + State compression stores account data on the Solana ledger instead of in millions of on-chain accounts. Only a small fingerprint of all accounts is stored on-chain for cryptographic integrity. Using Light Protocol, programs can use the account data inside Solana's virtual machine as if it were stored on-chain. + + + + The protocol uses 128 byte zero-knowledge proofs (validity proofs) to verify the integrity of + the compressed accounts. By default, this is all done under the hood. You can fetch validity + proofs from RPC providers that support ZK Compression. + + + + \ No newline at end of file diff --git a/snippets/jsx/partner-logos.jsx b/snippets/jsx/partner-logos.jsx new file mode 100644 index 00000000..94465bc1 --- /dev/null +++ b/snippets/jsx/partner-logos.jsx @@ -0,0 +1,24 @@ +// Styles in style.css - uses .partner-logos classes + +export const PartnerLogos = () => { + return ( +
+ Light Protocol + × + Helius + Helius +
+ ); +}; From a3c64643b9314fdf1e082526a27a25934d433113 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Tue, 10 Feb 2026 23:22:32 +0000 Subject: [PATCH 05/27] before rebase --- home.mdx | 2 +- images/helius-black.png | Bin 0 -> 5355 bytes images/helius-white.png | Bin 0 -> 5654 bytes images/light-wordmark.svg | 8 ++++++++ 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 images/helius-black.png create mode 100644 images/helius-white.png create mode 100644 images/light-wordmark.svg diff --git a/home.mdx b/home.mdx index 5f4f69be..b9d645d8 100644 --- a/home.mdx +++ b/home.mdx @@ -186,7 +186,7 @@ codex mcp add deepwiki -- npx -y mcp-remote@latest https://mcp.deepwiki.com/mcp ## Resources - + Learn core concepts of the Light token program and ZK Compression Core. diff --git a/images/helius-black.png b/images/helius-black.png new file mode 100644 index 0000000000000000000000000000000000000000..af570ba6080585683344a05b5139588fdc899afe GIT binary patch literal 5355 zcmW-lc_7pO|G?j_(tOYdQHU-dxhqGGG945$Wm&E{bIg6;Lxhind_p;9QM1Ibv5C!* zgs(d{vm#fHnR{lA-}?RWK3>n)`+2>N=llJBq&$S&69h?u000m)zJJ#O0Jy=N`w0GH zob$*v13%8?g#Uf(AOH{${c~^uc?G9ALarc-d$)m#UgG)4qfYqWj+C#{T;?;c+)dWp$vDDRn5{_k1qf8<_>X9x)a2-|%mo83sG)yi`NfR&Cwy@YQvlEm(%iejkqQ976euF`ftha+VQ{^^&n>Csdt~uSJS_Fxd0&Xox4fghL#hx=Q+J?{vPSTvqg&@@#Eif{6Jg} zzSz0zxz&!Fr+=V2LHN20_3FbjiZMItwdN;zf#zdb{E^O4`h?0_zMV&2yLDONGS@Hg za|4b<6JCLJBE$U!v=Lx>R+zfVknnyh4?T>?*ni-0L7zkMPs;S127{(yhP?0OGyZ z40Pa*;+H;@lZQQQPX0I01}aBw#Mi@~Mgzc@H1=ebbl1ojoj5Q;4b+8CxzJVD10FN! zsHB8K6V8kjAHMI}1bs;)#)@(Ot9mdBJ|+*rZl|_+rC%8JYAb}2*_`!w#S}B>hTO}& z%o)b2aHu-?s%emM0B^3|ntGIXtm4yG^|T`w>d!XOo4q49hNpci<{J+#a~{V1RyGE>Aoc;CoCps@F>r66 zsq0sukA15nK^o91I@qWbD5hQK9JP2|Cz$psr5Pp!JbIy7u~PV*?_ z^7`o&B4v2j!=-ZhIx{>H)%%*ZLvPTU3s=J-w=nbggw2MM>fc?(TbS-Sb;Absp2cR( zgiK{}ce=!@%2PQV3ejT`_3TcAjKNJNJ#hp{Ir{f!w_uD-BH*_4j8IXbd0hWd16x-U z@T|cZ3(_+fMwDr%LI^cH);eELrOC_Hn9@T0pVxtY_DFOQD`rrm$pfjWe`krkLoUhP zi!$B5%d7wPkE0U{j&uLi=G8tO9;jK*7x~hsG*=y0I5IY*`P4^v{xLH6W( zH_h7P(MydDu)T-l4q2;uKDJoOO!kE4?`&osm)8y!SgCHt4rmb%j-&-*C@qFVswE2F z+;IbhGojxZyvvH-qO0!Ni?j~p-T^7#hk)ZU>9INghbnJ#jL%ZdlfXdb-G~YH4+UNW z7r3PhO&vwDUI==b7Az%jIzJOFyHvZ)-48N&`o4~2qi2~W2u2F zZv|aD+Z4AO;^-H4x#CT_^Mn1@z7|a_*a~jy#sv6mNBlEm{{2XQ_Ti5EWgmuye(`c? zoX^tTHxeg%;4p-sP|WF0`p%2}Oe+0C^zm-oQ1WFI3j6^`H8)%T;dK zoi7@+88zizreVL^4yM|b(xi5+$zJxsVHkpFspZ5~wh@BDA9KZAzW!AlM$z)nQTDR8 zXO89Y06i=!0uyi%oKfnY<97c|WOpM>aw!II%uhG7e%-~5KJrXV;NM9=4+*$k-`F(j zGEIZ$q3jgeSJW`;+<^C^()zw51ZMna%-T$ry|iX1S32U_hh;HH&DAiInY(x?z&mp= zI`phxjm5!~yu3y9li&K`c}@;~hd3nHtp2^T2FsM-@i zm5f|G+R_2+yf!1s@ROkV&gyIN1js#b^}?p{WuOLLyqDvC1dQd0Xx57FmWM{XJiY%C zehw zPW<~iKO_#vy%>-Eo38HSw~Gr`Y$hKmrt&LIKVG7Z;%{%lgr6-9jf(tc8+Y};m^wZ- z>TrcDR@t@lPwTnMs)Py8Vl}2#UQkg@>ay2&oP|x;6e*Ia>G}aR9@+0QULge+E|CWO zeGmAmM_YagHF=4Tg@AH@{>)}^{Wdjo5uSpH4HiOi{itt*^D`^^<-7pZP4;cWNSA`0 z6iyS=S8K}prk2&G@Y3kQnvUT0wQ7^|)V9f+K-^Va=P7*$vWXLH=|e^14~b-Xvddu zInCWOw0;?a$Y9+|c4i_E@DiWtP|D*r(t?m=Z4r^5Zt zye(eV*7-~QlR$MH$XmtQSCc83VL)5}abPsjP5^u5;qOe&zI9JiLj?R)4Kh~`IR%&h z6V~S^AW^BX2_dr9$bnQkr_4MXC@uKN&TT>H>itjAE{OR-r&0W!_7p@th(65L+f*H6f&O-V+_HBh9yD5XowFLL*veA{;W#ZB(wq=R4mHj>xyGc+ zXGm`F-p4V`|`h2o1xxSdo2Zl{O z&HT8{unibQE2b7xogi~Y5oZL#%MIvyiK8_lAyPn&%WCqvm#nvXZTGCKkNT$QK@qEQ zDPw0ztlo(8n%Qi>t+#%Gt={T&D9=^aTwCnM(Kh*+q(Yk5k>!tb&0{yt1=B_g>SROB zhoRMCei}cox4VU}iYOb??K+u0RQy@Gd4rh8u<=?^ z>^Z86TKwCp>=oe?*>E~wr3vn#LVl$u^+94BeP=~@Nbbj|{c(YC<%{lIrB6DBLb&6$ zJv1FK%j9`0LGP5i24y}$is$5Z$48f(v^um;SeT&t)A|=Q?0-`nnr2R23k-JWvQmnQ z_0mMcg9<9{m9|%Jcbj8at0lZ(WWavI=p9r)-k>AJiGkeCq~c=akKGtz0As}>Jbsf% z^6(tbxvt%;JoCPEQ!G7D5!xR^$o)kBMv|z1begows2FELK5qFxC?|rxyb^tYX>XUW zCDyB^&EG^TSVOM|aVop*f(tGL6(kqY1AY^DQ=zKwFl50Z^(LFW1Dh)}#n1zpbck#E zOzA(NhcBOe2F7@5MV-3T{dE&(`W5$Y`Le8}p$ND{vC(E>U)n}pE_?q8FW6Ln!DJ&Z zR@E%P*0Jdz6ub5#Fr8@^Tio7ch=+Yb-_Jexv4iP-Km0X6p+{l1h8ANQbsh(M;j3(? zXS?aQxKJ7*s-fF}wF!mK)TKj(@*BUFNn_U}$0KNp59Ta94?bxZRT3E?dBU7xrHge< zua7Aq2*l)Pz>^n1F?+vK+~m8&d4MDZXNBGzN&O-b;zfm(gYtnu)Ux)RM_5l;xmC`0 za1$LlUU3g4vvjNeVv|%pZk*}OY#2m@vAA4&Sl{P2jvI9X^`ZUM;O)XRnn%HAHBz&;iu64KZ&t+ zyIMY(uOd{`d~7qaVo<+rSjLomasg&dg;;Rs9Wp5Wdz7KCn_i-^?T88gM$IAjyV>)o zSzLwb`-r{;Bi3X$vZ81%`r{|HwcQGgj^HNW&eb>2I;UP!1g0bj5xm!4{~We0Y_hZ= zUWd4cJz1L3z}gZhl)@<`I9&uS{WxNX#BeNsup5!xHv)lYK>f(ExT(K zi&O!SxL3b~RqkPZcnwf3o63Jvq8>?jwy#%L&Dm#as7v*EXAkC*6bxKp#;# z?MgR7W2f9*zV0c_jp~Ou?_TilfEi`>5^G)tU<03h(IhNbZm@8r(#|i!Z-8IxO)MXu zyGP4TcMnX*RZiEG-~MrWR?xLxS1^CWt~Tq~F^g=Q(?N7yl}+sskm$Gh9V0vP=Mooe zAZc>WRW@!VT;{=z*<)Z*rfe2i$4RrQ;XF~M_urJFg{5rtB0;wt0_?zN zo+C#;4ikoL+K)FwrX$8QFEJ-{TM<&w|E;8kbY>q*U&ykgVY|sw8Iy$@xAhXgtJc<6 z)PX3s`(N9<*VwWPGJnW!-82D&igv+0|1BZY5e({eCjFj@8vhFkMASa6b8|w5J>_Ek z<@@qX)>OL&NTL3*ImejjTx259VT0+aIw$WI8F1eT+NyI?rSpbwP#Y|GwPY@=$f5GjpJ~fgy<7{zjpVHR z?x7%BIw0f%ThItCFbT!mrMiv&nt+dr0AqNPSGKF1E$YXFdkATUWj`IRmFKV82d8$a zw!V?fofEreFrs_Y9#cDb12QeVu(-NB6o;)GjD~`G-*iA`n>1*|hSENyzQW)o>1*z2 z(_xRiy2|eZ8fTdBU-*b>ubuNWB}#_vdgUO?DsFsdLMH;Z5S=d2+cvV=*c*vH%9yWK z&BwE%S1zp`_hpiQs`LoG;Jd}x-fc#NMcE}XjT!99Q-!9KhMFQ5xL0(|8;r4e?ghR$ zVi1V2i61|rH^lZvHS(Pag{O?7!WxcdOtSf7UK)aD>alw9&Xsu4?|TV9 zR}LMPqwg&0B_7gTC`kzhWtEarX2*cHB}dP!bPLb#xmSj?%v-~Ljpa$Mb}+P2?q(UV z9axNC=-GCZV*{`U#dD1{!+5DFF z>;DLfKC3U*b-0qD_3pZG@!w`GhiK`s*wuXwOPk_ei9gGemsM_x?Rpv|ga>9Vr`uiV z|M)Ov6Nup}o*dTlZP$8{>)+uTJ4I^H0}R3Xoy}rlO7n3b&XR1I3%uX*xQx9b(Wa@d z#lahnY4d#IIXb$oJ`XS~>vw-}iefivnl)gt(1f=sTman~ctWQBYJH4Ll7H_R$}H7H ze%gX?fR`R|LtP;!W&H#-z1m#ZrwjDbFAJvh7-1vc!J%Z1?bojBJbRwjW|I5jMi^Oq z=s*AnJ>-fT$sKU=` z*cxAsJkGpa6?>P|uH7RXU2c8$A%s*SGcL{n74neegrw0X4O+DLw}f)bAZUA$Jv#$9Z(@KTuu|L+`OGoGvFqMGXJE|CRs&ZWintJt>1_FMn}0Orhsp2}JP008Ey2zFNPu|xm> z0Om%6oSm#sCg zTj%eS=XIWU-8X_D007{{Bj~x~d3_&TxK|$6yYaZ5tt+!mi2wiq)LD>l>HPijxX!kz z?R|QO)SO@NQ`x#Q2ulP204$p;gPyGmckOZAApy#+wCB3d2VCd2*e)DF5C8znQXKrB zyD}5<%MEwYa~pkA+kFC+=N;Fdx^XTXK@b1{^XB3NJ(V{-w{`8tTlYMc7?0z^5d;AM zFi(+!1-0$D9p9<#eLAPU7k^v3cv1lX0Q2I8)yXtj_1wD$A0RX@R zSgF4U)7o1=gWKUFOL6006Ko7BFbQ(w42!)3vC$x8Iflc&+>rFYte8b`}MK7Pivnux-zR% zZAu?gR$Tr@0002SaPg+L_n|l$0Dzeol=&$Ff#*-1$#CURl(xD^8vd;J?W)*v+iq%G zU6pZ4YTJpOwrf*7=C=X>046Os_;F=#EuE=!J47XAaPiZA=0$+;Lk^(0A0LVzYy0ni z#rDnaPZlz4)^gqY_;k}^=l{ulFmzg6cP0m5nI^pt`tw8{259e#`*AJ+03cXU@M8yL zpN07}2+`oE3X1gqKVoHz?0#qv_F2kcCzCz0x};UHy(n($R3fqLRU&1OquUF)4|uxh zzI-hJ03g_q%#W^plgcnvwx|k>s^5bGqo*2n)1WIftF#l~=)PB5T1A8~^|V z4GDhEiXWdOzA7-PXNztQHH5=a0G@^`dvC>dCNtr}8o2sO1&v&p zjr`!spga=*i{Q#SRL#0yxH3DQ3eaP4Z!cG7XLQY<7+D&v?|J*|*|TplBgH;i7e78o z9J+wyOTjHy7Qt7GP^R+mb$C_mt5lAJeHbS)TpqfXmAyaT2)y>4yIXJpG@@FGyA;#SLVIHzgNGE3Vt-TSnMzjV219fw{s4BDiH#p z&5{;1EcTVY`83t8RUZ+IqOXq``+x6&UlZo2;1GH#m+ zfJ^|~DvlL8n`@EfCMMfG;ZgA8?pM#;^{M#VztV0a-9m)d>H5<+XpQdr! z#L@f|%XUSE87SGv&03c2(d37w%uiF`Q#o%N0<#aBtmSf7F_$-=5gq<&%l>3-7qaJ| zt6(h^V7VCb0`6VPvNcYAXbOH(X{Q;5uBGZBR2c1ZJ%{z%K9qxQvsHX;0KVq z9%6|sTjS)1rr_s)(k*rEeMK^PoXNOi%4w&j>`!ajzP9XpmlFY&DQCzFxD%_f_LMb# z844Zts-#UPS|($6Y;7ZG)sp?$bX>%zXwBz21m@_w0I1qlB!aBz#0R~-T-jaSr&zWt zJET$8JNrGS*2jzPvnoRG+h;ym9qr2dioQk|N!R4cWm-ZO5C!IJC2{HSQ6^=Vg2^0P z+A_hrjZIVWlSumwX|vPJt}7Gt(jX;ZpS=`6sZ8hvilf935-?q{${+L##oM{{;@lnf zO2tpo^Y<$COlt;zzWeNj_@V9x02ZiY$(m3a_`IHD6Y|~Q$M=Al_xycRY(E%w38F79 zpMCb9_(=r-utc%yKHtwZ`+FDs*es&N^KzXBU@PK%EAVD7u=gHk-HM;2uPq4xV3raY z?`F<5yYM`0 zG&u!;#fcI8%=-9o8~k*%tJw9nFY9C7##e%&F8YGUfZ}LHAPNA>5~Jo;1E1Np$EY$t zeFsRdMUIMtw(clxx|s`x`dw_-#lHNv>r7UK?~?%{_yK@r$t8|6JFd@875tY6)-#-=m_OIeOXsxrdA+Xmrbh(nU$T_KJ77FN#zMg6YR^Fj&$5MS@m2SuhCs&Q#(k81U-6i z{VEKr#FjUl<`n={LZ8bSIm;m^~L7cciv`C>~!fWjn1eq1oR*WdI9& zE`?&+L(%{!DV|{3hV;|d=Sl!z+4Ku@D)W^{S!=Av$4&9`qi+!OhXk^sr)web*_Wi_ zZ#w4sm9={S0DS@%#htoUv2A^4rv(K+7Win!ClNfAH^p{I00aQ=;JYa9Txb^Px^H%x zckmM!`1qU$&3u9y&ARnIxd4D=vtgj6l}qR`^0Mm~=@tCgio+opAF>j|B?0HVBme>c zbg>1By(Y}eNFp7_$ll;*K;R=n=4Xt*0?wNV0T2M7M-c$6g#hSIXYgY!7PPoIG?SAE zh6*htPo#WuDL@ARw6Xxmw=d*eBvLNR^FV9xW33f7G7PH<4`2bzkRiiF2!H?pJ&FM6 zy!i1_mbEabcBo(1PiPE&Y7I( zqu^(!LFpK81ffzHueTv8001@&rp>WG%Q7-ScPsxt2!0|4K8hijaIxATeDYoB2>`HM zmIXSqOwd2Y_C@BK4N9x*&t33iy^z)t&)))X_JqU?7}o?q003V)CBE2J#rA(vW`wjj zTC+mhNL0JI|0mP8(trN6+MG`kzZa6${iI{Mt}aX}@dY(R1$Mj)Z59Y%9<(v4lpWNc zj7{Q6i|w7nn?J6P5y)+{fj0go1_ol04= zv7&ARz=VwbGJfonZN`?F+!UYbi_84fe3$Y5x|{7~)7{Q(xIhD;w~=lnCHvDUmGR#M zv;tp?noqS#-=-~Q3x9(En5MCxTgj0hbH;wz-PcIXRD6^1UN)}qY=O|G*fc`bDR0%> z|6GP4`_sU(K1277X6Q6ir`erE(}B#a126-bjCYhZcExA@O2&WLebO0NbJ5$?U9$(Z zx&N9G(&3cQ)ga0KG}AX|;(1>EHlzWMX5=)xlUk-O7XX-#OvYOs+cC$Mm5GrE$Yj|P ziJ&+5*=55i)oPH{B1k@ULKlKNmi1ZpoNc#$C$)?m!&v}k$v)pQ8SkRr%jpQ{F))$w zmY(@p$#~n~;HOUK;5XC>wFN@SZdcWXTeqC9^*gr#5A{0$7AnTXo21w-pE>~2jE{9t zh_RmD)snOQ_FTp&X#a0i@KaZ-6H4V_olyOt{qD#j@h4&9zV$I_eWPo^a#g=`M*R+e z1&g&VSyF7*?unW`+tAyk#9MA;BMW7*gYL^1i&*}M7W~xh)Cp-Iq{B8URJj>d=?EZQ)dW_HOly=OKD}0`!0}_1EdufesiaHncHSS4VhY)ogew@g!2# z-RSE&lX5ASAJ#%)6bqZKDUjl}y*6_LDdL(riIWDsky^^~N@_mI?Z~tjD8V?mL&~Etjn} z?b-Lreoth-av3+|l?p5US2p_3!GoWgSH+9&Mezb39L-LNjyW%^xhQZ9GJ%gwj+2%K zT+9B&&Mw6Eab#Hpy#?=O`cF{JPjLW$Q*2*t?6gh`%FY9ene$@XL~8PO)NH)+odl}J zI(6*0*nZXa_b)qbq|Q?fQP;b zd>r+DvW$5q%alu5`!q%>P`T9hWpD6fQKJSuiTGKGM?h2irlHrbnWNdI(mPKojP9tRHI5w0X3>|v4w~+9(V^hk?)5<1&eqQzH`zqfaW|a)Em}lMB4$Qy3bw`>0E%5x_0@aLPJ%dRAR#z8JjUj&*gVisuxlgb#^0-(8O_4IK?34F}bhrDk0XVV`-S9sQz z6}g1zT2ZsD2sn|lczP1UU{;{4L0;F=+j-B`40)`v(xSke+|VAzOFqT@WUZ96srJ}H z;A2zubj&55B@cP&7ogL&^#p^0AG;C_fNmtrs^#>)>sePzlFN~@o-ta_bJla#n~v*9 zB|J6xp1=oabaV^$9jQzv%tj;TFbtMUd5}JP7IEQU8$FrrOzIA|b;{OWt95?{_x2jN z?n2sfy3Z4x6x)TZYm>^6s7?RZjE_%^QrBY*eSv;t!9<`H#s7XLQ}5G8Ggrm-Ql>c@ ztU5@)+*1ZFmF3YdKCgX_kAoVUS^@OufQy{8oE{S8rcxGAUp`eP$cDGhEa(ZHl@%-a z`9Xm*&?yu6$Ydt;m^7gvsA_8ca?f94m$a(02J)xYBs}-Iz~J^4nxZR$01awV87`M_ zscu#eloi{TeUDpP#z_mu^u;uECR&ViW-jHhBY#(17Poqz~kO7V^QaFJ$i(v0E;GOvXMQpJfu7jJeIJ+Q=|tpQEYS1e|wr`^MHi z`(`znsg$4NTKt>H;b?{@)9ncg%Tt-p>$z$;TWy(?#rmT@=by<)wvb`hEGMPkGSY_2 zrgqubbf;)-(ocD~%0f6CZMZndj z|JTp{F`xMwWax3FI_}(VbIh#G$>`umS#;gCp3ldoIu#3?4$-k!=?n3#eIxJ{?_eZZ-D0> zc5M&3EC2v_BCec?wd;C`%fJ3t&q6%nyvM#xc%PZT{a$ht6Id}10 zc;0^E?)TkV006)=xN;#tuK=Vt-?fV;DBIIMq$7Lkozh)LH}cpZBU9P1psk~qtyv)%&$07qi%3eQi?YyBHn zPIG@F<)T)9*~!(yR9V+zRJvTcD`#u1W%yF*xc~qFC^u}H`PO-Kcz0#}%w^AYX@T*D z^QaYa!)t+30RR9{t}KoYp|i1imm(io zVOj^|ovm@*bxXel005xU5wLu9fx|^E-kL#b9eCSqSs)sd0sw$}u52k$r&*Vk1ak2^ z#1G2YxW`$bOaK4?>fC+CW^j87=U+G-Vo+mI_b>~z761T%U2f!baJQd^q$?T0F~uDK wfTME^?JaI;I|&)*MB+ + + + + + + + From feaad46cdd59f686f1096a44cdee04f1a8c95f74 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Tue, 10 Feb 2026 23:28:13 +0000 Subject: [PATCH 06/27] finale restoreation --- .../guides/how-to-create-nullifier-pdas.mdx | 1 + compressed-tokens/advanced-guides/airdrop.mdx | 1 - compressed-tokens/for-privy.mdx | 2 +- compressed-tokens/overview.mdx | 13 ++++-- learn/light-token-standard.mdx | 2 +- light-token/toolkits/for-payments.mdx | 4 +- light-token/toolkits/for-wallets.mdx | 4 +- snippets/jsx/liquid-glass-pill.jsx | 3 +- snippets/versions/rust-native-token.mdx | 7 +++ snippets/versions/rust-sdk-macros.mdx | 5 ++ snippets/versions/rust-sdk.mdx | 4 ++ snippets/versions/rust-test.mdx | 5 ++ snippets/versions/rust-token-defi.mdx | 6 +++ snippets/versions/rust-token.mdx | 5 ++ style.css | 46 +++++++++++++++++++ 15 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 snippets/versions/rust-native-token.mdx create mode 100644 snippets/versions/rust-sdk-macros.mdx create mode 100644 snippets/versions/rust-sdk.mdx create mode 100644 snippets/versions/rust-test.mdx create mode 100644 snippets/versions/rust-token-defi.mdx create mode 100644 snippets/versions/rust-token.mdx diff --git a/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx b/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx index 63f10de2..c6a72025 100644 --- a/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx +++ b/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx @@ -1,5 +1,6 @@ --- title: Create Nullifier PDAs +sidebarTitle: Nullifier PDAs description: Create rent-free nullifier PDAs to prevent duplicate actions. keywords: ["nullifiers on solana", "prevent double spending", "compressed pdas", "rent-free nullifiers"] --- diff --git a/compressed-tokens/advanced-guides/airdrop.mdx b/compressed-tokens/advanced-guides/airdrop.mdx index 78a88f13..5a8778ab 100644 --- a/compressed-tokens/advanced-guides/airdrop.mdx +++ b/compressed-tokens/advanced-guides/airdrop.mdx @@ -1,6 +1,5 @@ --- title: Airdrop Guide -sidebarTitle: For Airdrops description: Complete client and program guides to create an airdrop – with or without code. ZK compression is the most efficient way to distribute SPL tokens. keywords: ["solana airdrop", "merkle distributor", "merkle airdrop", "airdrop infrastructure on solana", "scalable token distribution on solana", "token airdrop for protocols"] --- diff --git a/compressed-tokens/for-privy.mdx b/compressed-tokens/for-privy.mdx index 035d3061..c9ba48bc 100644 --- a/compressed-tokens/for-privy.mdx +++ b/compressed-tokens/for-privy.mdx @@ -1,6 +1,6 @@ --- title: "Rent-Free SPL Accounts with Privy" -sidebarTitle: "Privy Guide" +sidebarTitle: "Sign with Privy Wallet" description: "Integrate compressed tokens with Privy embedded wallets for rent-free SPL token accounts and transfers." keywords: ["privy solana", "privy compressed tokens", "embedded wallet compression", "rent-free tokens privy"] --- diff --git a/compressed-tokens/overview.mdx b/compressed-tokens/overview.mdx index cab4c9e9..0dceae4c 100644 --- a/compressed-tokens/overview.mdx +++ b/compressed-tokens/overview.mdx @@ -10,9 +10,12 @@ import SetupEnvironment from "/snippets/setup/setup-environment-tabs.mdx"; import InstallDependencies from "/snippets/setup/install-dependencies-codegroup.mdx"; import { TokenAccountCompressedVsSpl } from "/snippets/jsx/token-account-compressed-vs-spl.jsx"; - - **Compressed Tokens are supported by leading Solana wallets such as Phantom and Backpack.** - + +**Note: The new [Light Token Program Beta](/light-token/welcome)** is live on Solana Devnet with mainnet expected in Q1 2026. +We recommend to use Light Token for most purposes except airdrops and other forms of token distribution. +The SDK for compressed tokens can still be used once Light Token is on Solana Mainnet. +For production use today, use Compressed Tokens, which are on Solana Mainnet. + | Creation | Solana | Compressed | | :---------------- | :------------------ | :----------------- | @@ -22,6 +25,10 @@ import { TokenAccountCompressedVsSpl } from "/snippets/jsx/token-account-compres 2. Compressed token accounts are rent-free. 3. Any light-token or SPL token can be compressed/decompressed at will. + + **Compressed Tokens are supported by leading Solana wallets such as Phantom and Backpack.** + + ## Recommended Usage of Compressed Tokens diff --git a/learn/light-token-standard.mdx b/learn/light-token-standard.mdx index 3327c50b..5957e96c 100644 --- a/learn/light-token-standard.mdx +++ b/learn/light-token-standard.mdx @@ -1,6 +1,6 @@ --- title: Core Concepts to the Light Token Program (Beta) -sidebarTitle: Core Concepts (Light Token) +sidebarTitle: Core Concepts Light Token description: The Light Token Program is a high performance token program that reduces the cost of account creations by 200x, while being more CU efficient than SPL on hot paths. keywords: ["light token standard on solana", "token 2022 on solana", "token extensions on solana", "spl token on solana", "rent free tokens on solana"] --- diff --git a/light-token/toolkits/for-payments.mdx b/light-token/toolkits/for-payments.mdx index bc1cae9b..677473ee 100644 --- a/light-token/toolkits/for-payments.mdx +++ b/light-token/toolkits/for-payments.mdx @@ -1,7 +1,7 @@ --- title: "Toolkit for Stablecoin Payments" -sidebarTitle: "For Stablecoin Payments" -description: "Guide to integrate light-token APIs with comparison to SPL." +sidebarTitle: "Integration Guide" +description: "Guide to integrate light-token APIs for stablecoin payments with comparison to SPL." keywords: ["stablecoin payments for enterprises", "infrastructure for stablecoin payments on solana", "payment rails for stablecoins on solana", "usdc payments for merchants on solana", "payment infrastructure for fintechs", "micropayments for apps on solana", "token extensions for payment companies", "rent free tokens for payment apps"] --- diff --git a/light-token/toolkits/for-wallets.mdx b/light-token/toolkits/for-wallets.mdx index 99fac62f..20f3047a 100644 --- a/light-token/toolkits/for-wallets.mdx +++ b/light-token/toolkits/for-wallets.mdx @@ -1,6 +1,6 @@ --- -title: "Toolkit for Wallet Applications" -sidebarTitle: "For Wallets" +title: "Light Token Integration Guide for Wallet Applications" +sidebarTitle: "Integration Guide" description: "Guide for Wallet Applications to add Light-token support." keywords: ["wallet infrastructure on solana", "scalable wallet infrastructure on solana", "token wallet for developers", "rent free tokens for wallets"] --- diff --git a/snippets/jsx/liquid-glass-pill.jsx b/snippets/jsx/liquid-glass-pill.jsx index 05670a24..2e721839 100644 --- a/snippets/jsx/liquid-glass-pill.jsx +++ b/snippets/jsx/liquid-glass-pill.jsx @@ -1,6 +1,6 @@ // Styles in style.css - uses .glass-pill classes -export const LiquidGlassPill = ({ title }) => { +export const LiquidGlassPill = ({ title, children }) => { return (
@@ -8,6 +8,7 @@ export const LiquidGlassPill = ({ title }) => {

{title}

+ {children}
); diff --git a/snippets/versions/rust-native-token.mdx b/snippets/versions/rust-native-token.mdx new file mode 100644 index 00000000..e77600fa --- /dev/null +++ b/snippets/versions/rust-native-token.mdx @@ -0,0 +1,7 @@ +```toml +[dependencies] +light-token = "0.4.0" +light-compressible = "0.4.0" +light-token-interface = "0.3.0" +light-compressed-account = "0.9.0" +``` diff --git a/snippets/versions/rust-sdk-macros.mdx b/snippets/versions/rust-sdk-macros.mdx new file mode 100644 index 00000000..cd5fc463 --- /dev/null +++ b/snippets/versions/rust-sdk-macros.mdx @@ -0,0 +1,5 @@ +```toml +[dependencies] +light-sdk = { version = "0.19.0", features = ["anchor", "v2", "cpi-context"] } +light-sdk-macros = "0.19.0" +``` diff --git a/snippets/versions/rust-sdk.mdx b/snippets/versions/rust-sdk.mdx new file mode 100644 index 00000000..110d90ab --- /dev/null +++ b/snippets/versions/rust-sdk.mdx @@ -0,0 +1,4 @@ +```toml +[dependencies] +light-sdk = "0.19.0" +``` diff --git a/snippets/versions/rust-test.mdx b/snippets/versions/rust-test.mdx new file mode 100644 index 00000000..ab8e5c69 --- /dev/null +++ b/snippets/versions/rust-test.mdx @@ -0,0 +1,5 @@ +```toml +[dev-dependencies] +light-program-test = { version = "0.19.0", features = ["v2"] } +light-client = { version = "0.19.0", features = ["v2"] } +``` diff --git a/snippets/versions/rust-token-defi.mdx b/snippets/versions/rust-token-defi.mdx new file mode 100644 index 00000000..dbaa0a59 --- /dev/null +++ b/snippets/versions/rust-token-defi.mdx @@ -0,0 +1,6 @@ +```toml +[dependencies] +light-sdk = { version = "0.19.0", features = ["anchor", "v2", "cpi-context"] } +light-sdk-macros = "0.19.0" +light-token = { version = "0.4.0", features = ["anchor"] } +``` diff --git a/snippets/versions/rust-token.mdx b/snippets/versions/rust-token.mdx new file mode 100644 index 00000000..e51ec9cc --- /dev/null +++ b/snippets/versions/rust-token.mdx @@ -0,0 +1,5 @@ +```toml +[dependencies] +light-sdk = "0.19.0" +light-token = "0.4.0" +``` diff --git a/style.css b/style.css index 642acdf1..9a0ae850 100644 --- a/style.css +++ b/style.css @@ -219,3 +219,49 @@ html.dark .hero-title { font-size: 3rem; } } + +/* Partner logos inside hero pill */ +.partner-logos { + display: flex; + align-items: center; + justify-content: center; + gap: 32px; + margin-top: 10px; + pointer-events: none; +} + +.partner-logos img { + height: 28px; + width: auto; +} + +.partner-divider { + color: #9ca3af; + font-size: 14px; +} + +/* Light wordmark is white SVG - invert for light mode */ +.light-wordmark { + filter: invert(1); +} + +html.dark .light-wordmark { + filter: none; +} + +/* Helius logo switching */ +.logo-dark { + display: none; +} + +html.dark .logo-light { + display: none; +} + +html.dark .logo-dark { + display: block; +} + +html.dark .partner-divider { + color: #6b7280; +} From 5f4a49a2774b6f561da6ba97a46935ec6ffae0dd Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Tue, 10 Feb 2026 23:57:18 +0000 Subject: [PATCH 07/27] before swen review --- ai-tools/guide.mdx | 52 ++++++++++++++----- .../solana-attestation-service.mdx | 3 +- home.mdx | 40 +++++++++++--- .../light-token-program-examples-table.mdx | 2 + style.css | 8 +-- 5 files changed, 79 insertions(+), 26 deletions(-) diff --git a/ai-tools/guide.mdx b/ai-tools/guide.mdx index 7fc4325e..bf6813a6 100644 --- a/ai-tools/guide.mdx +++ b/ai-tools/guide.mdx @@ -7,31 +7,57 @@ description: "Guidance to AI tools when working with ZK Compression. Includes Ag - **Docs AI Search** - Search documentation with AI in the search bar. - **Markdown Export** - Append `.md` to any page URL for raw markdown. +* **View [`/llms.txt`](https://zkcompression.com/llms.txt)** for an index of the docs - It lists key pages with descriptions +so agents can navigate to answers quickly. # For Development -## AI agents +## Agent Skills -### `skill.md` +View or install [`/skill.md`](https://zkcompression.com/skill.md), a structured capability file that tells agents what they can do +with Light Protocol and ZK Compression. If you're building with agents, start here. -`skill.md` is a structured capability file that tells agents what they can do -with Light Protocol and ZK Compression. If you're -building with agents, start here. +```bash +npx skills add https://zkcompression.com +``` -* View: [`/skill.md`](https://zkcompression.com/skill.md) +Dedicated agent skills can be found and installed below: -### `llms.txt` -`llms.txt` is an index of the docs. It lists key pages with descriptions -so agents can navigate to answers quickly. +| Use case | Skill | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | +| Build DeFi programs (AMMs, vaults, lending) with Anchor or Pinocchio | [defi-program](https://github.com/Lightprotocol/skills/tree/main/defi-program) | +| Integrate rent-free markets into routers and aggregators | [defi-router](https://github.com/Lightprotocol/skills/tree/main/defi-router) | +| Stream account state via Laserstream gRPC | [data-streaming](https://github.com/Lightprotocol/skills/tree/main/data-streaming) | +| Wallets and payment flows with light-token. Includes privy, wallet adapter, mobile wallet adapter signing. Optional nullifier to prevent your onchain instruction from being executed more than once. | [payments-and-wallets](https://github.com/Lightprotocol/skills/tree/main/payments-and-wallets) | +| Airdrops, DePIN, token distribution | [airdrop](https://github.com/Lightprotocol/skills/tree/main/airdrop) | +| Anti-double-spend nullifiers for Privacy-preserving ZK programs | [zk-nullifier](https://github.com/Lightprotocol/skills/tree/main/zk-nullifier) | +| Testing programs and clients on localnet, devnet, mainnet | [testing](https://github.com/Lightprotocol/skills/tree/main/testing) | +| Help with Debugging and Questions via DeepWiki MCP | [ask-mcp](https://github.com/Lightprotocol/skills/tree/main/ask-mcp) | -* View: [`/llms.txt`](https://zkcompression.com/llms.txt) +All skills are included and are auto-discovered based on context. Ask about light-token, defi, payments, or program migration and the agent uses the relevant skill automatically. -### `llms-full.txt` + + +Add the marketplace and install: -`llms-full.txt` is the full, expanded index for agents that want complete coverage of the documentation. +``` +/plugin marketplace add Lightprotocol/skills +/plugin install solana-rent-free-dev +``` + + +1. Open Settings (**Cmd+Shift+J** / **Ctrl+Shift+J**) +2. Navigate to **Rules & Commands** → **Project Rules** → **Add Rule** → **Remote Rule (GitHub)** +3. Enter: `https://github.com/Lightprotocol/skills.git` -* View: [`/llms-full.txt`](https://zkcompression.com/llms-full.txt) + + +``` +npx skills add Lightprotocol/skills +``` + + ## MCP diff --git a/compressed-pdas/solana-attestation-service.mdx b/compressed-pdas/solana-attestation-service.mdx index ab14417b..61f21254 100644 --- a/compressed-pdas/solana-attestation-service.mdx +++ b/compressed-pdas/solana-attestation-service.mdx @@ -1,7 +1,6 @@ --- title: "Solana Attestation Service (Devnet)" -description: "Build compressed attestations on Solana using ZK Compression. Currently undergoing audit." -url: "https://github.com/solana-foundation/solana-attestation-service/tree/a8fb187978ecea0b165e63767c7e6b1c036e7b52/examples/typescript/attestation-flow-guides" +description: " Credential system for KYC verification, professional badges, and compliance credentials in minutes. Currently undergoing audit." keywords: ["solana attestation service", "attestations for identity verification", "on-chain attestations solana", "identity verification on solana"] --- diff --git a/home.mdx b/home.mdx index b9d645d8..315e1414 100644 --- a/home.mdx +++ b/home.mdx @@ -97,7 +97,7 @@ while being more CU efficient than SPL on hot paths. TypeScript and Rust client examples.
- Anchor program examples. + Program examples for Light Token Anchor macros, instructions and Pinocchio.
@@ -120,7 +120,7 @@ while being more CU efficient than SPL on hot paths. To store app and user state without rent-exemption. Introduction to compressed PDAs.
- + Credential system for KYC verification, professional badges, and compliance credentials in minutes. @@ -130,16 +130,40 @@ while being more CU efficient than SPL on hot paths. ## AI Tools -Download agent skill or view [skill.md](https://www.zkcompression.com/skill.md): + + + +Download agent skill or view [skill.md](https://www.zkcompression.com/skill.md): ```bash npx skills add https://zkcompression.com ``` -| | | -| :------- | :--------------------------------------------------------------------------- | -| MCP | Connect AI tools to the Light Protocol repository via Model Context Protocol | -| DeepWiki | Use Deepwiki for advanced AI assistance with your development. | +Dedicated agent skills: + + + +Add the marketplace and install: + +``` +/plugin marketplace add Lightprotocol/skills +/plugin install solana-rent-free-dev +``` + + +1. Open Settings (**Cmd+Shift+J** / **Ctrl+Shift+J**) +2. Navigate to **Rules & Commands** → **Project Rules** → **Add Rule** → **Remote Rule (GitHub)** +3. Enter: `https://github.com/Lightprotocol/skills.git` + + +``` +npx skills add Lightprotocol/skills +``` + + + + +Connect AI tools to the Light Protocol repository via MCP and DeepWiki. @@ -174,6 +198,8 @@ codex mcp add deepwiki -- npx -y mcp-remote@latest https://mcp.deepwiki.com/mcp ``` + + Date: Wed, 11 Feb 2026 00:15:50 +0000 Subject: [PATCH 08/27] restore SDK 0.19 updates and GitHub skill links - ai-tools/guide.mdx: update skill table links to GitHub URLs - light-token/defi/programs.mdx: SDK 0.19.0 API updates - light-token/defi/routers.mdx: SDK 0.19.0 streaming-based cold detection --- ai-tools/guide.mdx | 16 ++++++++-------- light-token/defi/programs.mdx | 9 ++++----- light-token/defi/routers.mdx | 2 +- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/ai-tools/guide.mdx b/ai-tools/guide.mdx index bf6813a6..9416876f 100644 --- a/ai-tools/guide.mdx +++ b/ai-tools/guide.mdx @@ -26,14 +26,14 @@ Dedicated agent skills can be found and installed below: | Use case | Skill | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | -| Build DeFi programs (AMMs, vaults, lending) with Anchor or Pinocchio | [defi-program](https://github.com/Lightprotocol/skills/tree/main/defi-program) | -| Integrate rent-free markets into routers and aggregators | [defi-router](https://github.com/Lightprotocol/skills/tree/main/defi-router) | -| Stream account state via Laserstream gRPC | [data-streaming](https://github.com/Lightprotocol/skills/tree/main/data-streaming) | -| Wallets and payment flows with light-token. Includes privy, wallet adapter, mobile wallet adapter signing. Optional nullifier to prevent your onchain instruction from being executed more than once. | [payments-and-wallets](https://github.com/Lightprotocol/skills/tree/main/payments-and-wallets) | -| Airdrops, DePIN, token distribution | [airdrop](https://github.com/Lightprotocol/skills/tree/main/airdrop) | -| Anti-double-spend nullifiers for Privacy-preserving ZK programs | [zk-nullifier](https://github.com/Lightprotocol/skills/tree/main/zk-nullifier) | -| Testing programs and clients on localnet, devnet, mainnet | [testing](https://github.com/Lightprotocol/skills/tree/main/testing) | -| Help with Debugging and Questions via DeepWiki MCP | [ask-mcp](https://github.com/Lightprotocol/skills/tree/main/ask-mcp) | +| Build DeFi programs (AMMs, vaults, lending) with Anchor or Pinocchio | [defi-program](https://github.com/Lightprotocol/skills/tree/main/skills/defi-program) | +| Integrate rent-free markets into routers and aggregators | [defi-router](https://github.com/Lightprotocol/skills/tree/main/skills/defi-router) | +| Stream account state via Laserstream gRPC | [data-streaming](https://github.com/Lightprotocol/skills/tree/main/skills/data-streaming) | +| Wallets and payment flows with light-token. Includes privy, wallet adapter, mobile wallet adapter signing. Optional nullifier to prevent your onchain instruction from being executed more than once. | [payments-and-wallets](https://github.com/Lightprotocol/skills/tree/main/skills/payments-and-wallets) | +| Airdrops, DePIN, token distribution | [airdrop](https://github.com/Lightprotocol/skills/tree/main/skills/airdrop) | +| Anti-double-spend nullifiers for Privacy-preserving ZK programs | [zk-nullifier](https://github.com/Lightprotocol/skills/tree/main/skills/zk-nullifier) | +| Testing programs and clients on localnet, devnet, mainnet | [testing](https://github.com/Lightprotocol/skills/tree/main/skills/testing) | +| Help with Debugging and Questions via DeepWiki MCP | [ask-mcp](https://github.com/Lightprotocol/skills/tree/main/skills/ask-mcp) | All skills are included and are auto-discovered based on context. Ask about light-token, defi, payments, or program migration and the agent uses the relevant skill automatically. diff --git a/light-token/defi/programs.mdx b/light-token/defi/programs.mdx index 719c5099..a2fb3948 100644 --- a/light-token/defi/programs.mdx +++ b/light-token/defi/programs.mdx @@ -34,11 +34,10 @@ You can find a complete rent-free AMM reference implementation [here](https://gi ```toml [dependencies] -light-sdk = { version = "0.18.0", features = ["anchor", "v2", "cpi-context"] } -light-sdk-macros = { version = "0.18.0" } -light-token = { version = "0.3.0", features = ["anchor"] } - -light-anchor-spl = { version = "0.31" } # TokenInterface uses light_token::ID +light-sdk = { version = "0.19.0", features = ["anchor", "v2", "cpi-context"] } +light-sdk-macros = "0.19.0" +light-token = { version = "0.4.0", features = ["anchor"] } +light-anchor-spl = "0.31" # TokenInterface uses light_token::ID anchor-lang = "0.31" ``` diff --git a/light-token/defi/routers.mdx b/light-token/defi/routers.mdx index e6258e2f..bfcc3c3b 100644 --- a/light-token/defi/routers.mdx +++ b/light-token/defi/routers.mdx @@ -137,7 +137,7 @@ pub trait LightProgramInterface { ```toml [dependencies] -light-client = {version = "0.18.0", features = ["v2"]} +light-client = { version = "0.19.0", features = ["v2"] } # AMM SDK that implements LightProgramInterface (provided by the AMM team) example-amm-sdk = "0.1" From a6337245fa613539cf4de678311dd50c6ec3b0dc Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Wed, 11 Feb 2026 00:21:30 +0000 Subject: [PATCH 09/27] restore remaining content from rebase picks - security.mdx: expand audit table (10 audits through Dec '25) - terminology.mdx: improve Compressed PDA, SPL Interface PDA Account defs - transfer-interface.mdx: add create-and-transfer example tab - compressed-account-model.mdx: remove Compressed Token section, add Info - merkle-trees: fix "optimizes optimize" typo, remove "on Devnet" - faq.mdx: add Learn Core Concepts card - welcome.mdx: add quickstart card to Get Started step - sdk-reference: fix heading and icons - program-examples-table: minor text update - .gitignore: add 3 config file entries Co-Authored-By: Claude Opus 4.6 --- .gitignore | 5 +- .../compressed-account-model.mdx | 41 +-- .../merkle-trees-validity-proofs.mdx | 4 +- light-token/cookbook/transfer-interface.mdx | 21 +- light-token/faq.mdx | 7 + light-token/welcome.mdx | 8 +- references/security.mdx | 24 +- references/terminology.mdx | 25 +- .../create-and-transfer-example.mdx | 249 ++++++++++++++++++ .../program-examples-table.mdx | 2 +- snippets/overview-tables/sdk-reference.mdx | 6 +- 11 files changed, 325 insertions(+), 67 deletions(-) create mode 100644 snippets/code-snippets/light-token/transfer-interface/anchor-program/create-and-transfer-example.mdx diff --git a/.gitignore b/.gitignore index f6f2388f..4c892c3f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ node_modules/ stash docs-audit.md -docs-audit.txt \ No newline at end of file +docs-audit.txt +docs-anchor.json +product-docs.json +tabs-docs.json \ No newline at end of file diff --git a/learn/core-concepts/compressed-account-model.mdx b/learn/core-concepts/compressed-account-model.mdx index bb0355b3..51b5554f 100644 --- a/learn/core-concepts/compressed-account-model.mdx +++ b/learn/core-concepts/compressed-account-model.mdx @@ -20,6 +20,11 @@ Compressed accounts store state and are similar to regular Solana accounts but w These differences make compressed accounts rent-free and allow the protocol to store state as calldata on the Solana ledger instead of the costly on-chain account space. + +Compressed PDAs are compressed accounts with an address.
+Compressed Token accounts are compressed accounts that don't need an address. +
+ # In a Nutshell Transactions can use compressed account data inside Solana's virtual machine as if it were stored on-chain by combining state compression and zero-knowledge proofs: @@ -183,42 +188,6 @@ pub struct CompressedAccountData { - `data_hash`: Hash of the `data` field (32 bytes). - When computing the compressed account hash for the state tree, the protocol uses this fixed-size hash instead of the variable-length data bytes. -# Compressed Token Account - -Compressed token accounts store token balance, owner, and other information of token accounts (SPL, Token-2022, or Light). - -1. Any Solana token account can be compressed/decompressed at will. -2. We recommend to use compressed tokens for token distribution. - - - Learn how the Light token program uses ZK Compression under the hood - [here](/learn/light-token-standard). - - - - - - Diagram showing compressed token account structure with three components: Hash (identifier for compressed token account in purple box), Account (struct containing Data bytes, Executable flag, Lamports balance, and Address set to None), and AccountData (containing Mint, Owner, Amount, and Extensions fields marked as unimplemented) - - - - ```rust - pub struct TokenData { - pub mint: Pubkey, - pub owner: Pubkey, - pub amount: u64, - pub delegate: Option, - pub state: u8, - /// Placeholder for TokenExtension tlv data (unimplemented) - pub tlv: Option>, - } - ``` - - - # Next Steps @@ -149,7 +149,7 @@ Two **address tree versions** are currently supported: - **V1 address trees** height 26 (\~67 million addresses). - **V2 batched address trees** with height 40 (\~1 trillion addresses). -**V2** optimizes optimize compute unit consumption by up to 70% and is **currently on Devnet**. +**V2** optimizes compute unit consumption by up to 70%. When using V2 trees, RPC requests automatically choose the proof mechanism. diff --git a/light-token/cookbook/transfer-interface.mdx b/light-token/cookbook/transfer-interface.mdx index a315c4c1..09f07a3b 100644 --- a/light-token/cookbook/transfer-interface.mdx +++ b/light-token/cookbook/transfer-interface.mdx @@ -21,6 +21,7 @@ import InstructionCode from "/snippets/code-snippets/light-token/transfer-interf import RustActionCode from "/snippets/code-snippets/light-token/transfer-interface/rust-client/action.mdx"; import RustInstructionCode from "/snippets/code-snippets/light-token/transfer-interface/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/transfer-interface/anchor-program/full-example.mdx"; +import CreateAndTransferCode from "/snippets/code-snippets/light-token/transfer-interface/anchor-program/create-and-transfer-example.mdx"; @@ -200,7 +201,10 @@ TransferInterfaceCpi::new( -# Full Code Example +# Full code example + + + View the [source code](https://github.com/Lightprotocol/light-protocol/blob/main/sdk-libs/token-sdk/src/instruction/transfer_interface.rs) and [full example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/transfer-interface) with shared test utilities. @@ -210,6 +214,21 @@ TransferInterfaceCpi::new( + + +Uses the `#[light_account(init, associated_token::...)]` macro to create the destination ATA during the transfer. + + + View the [full example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/create-and-transfer) with test utilities. + + + + + + + + + # Next Steps diff --git a/light-token/faq.mdx b/light-token/faq.mdx index 548c55e3..638ad500 100644 --- a/light-token/faq.mdx +++ b/light-token/faq.mdx @@ -134,6 +134,13 @@ Coming soon: DM us [@lightprotocol on X (Twitter)](http://x.com/lightprotocol) or [Discord](https://discord.com/invite/rpddh53TeG). + + + ### Get Started diff --git a/light-token/welcome.mdx b/light-token/welcome.mdx index bb9eb1bb..277bcdff 100644 --- a/light-token/welcome.mdx +++ b/light-token/welcome.mdx @@ -66,7 +66,13 @@ import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; ### Get Started - + diff --git a/references/security.mdx b/references/security.mdx index 2cba2a01..4b7e1fe8 100644 --- a/references/security.mdx +++ b/references/security.mdx @@ -10,18 +10,24 @@ Light Protocol is hosting a [bug bounty program](https://immunefi.com/bug-bounty ### Security Audits -The Light protocol on-chain programs were audited by independent security firms Neodyme, OtterSec, Accretion, and Zellic. - -- [Accretion audit report](https://github.com/Lightprotocol/light-protocol/blob/main/audits/accretion_v1_update_audit.pdf) (January '25) -- [Zellic audit report](https://github.com/Lightprotocol/light-protocol/blob/main/audits/zellic_v1_audit.pdf) (September '24) -- [Neodyme audit report](https://github.com/Lightprotocol/light-protocol/blob/main/audits/neodyme_v1_audit.pdf) (August '24) -- [OtterSec audit report](https://github.com/Lightprotocol/light-protocol/blob/main/audits/ottersec_v1_audit.pdf) (July '24) - -A complete list of 3rd party audits can be found [here](https://github.com/Lightprotocol/light-protocol/tree/main/audits). +The Light protocol on-chain programs were audited by independent security firms Certora, OtterSec, Accretion, HashCloak, Neodyme, and Zellic. + +| Firm | Scope | Date | Report | +| :--- | :--- | :--- | :--- | +| **Certora** | Light Token | December '25 | [View](https://github.com/Lightprotocol/light-protocol/blob/main/audits/certora_2025-12_light-token.pdf) | +| **OtterSec** | CPI Context Refactor | December '25 | [View](https://github.com/Lightprotocol/light-protocol/blob/main/audits/ottersec_2025-12_cpi-context-refactor.pdf) | +| **Accretion** | ZK Compression v2 | June '25 | [View](https://github.com/Lightprotocol/light-protocol/blob/main/audits/accretion_2025-06_zkcompression-v2.pdf) | +| **OtterSec** | Batched Merkle Trees | June '25 | [View](https://github.com/Lightprotocol/light-protocol/blob/main/audits/ottersec_2025-06_batched-merkle-trees.pdf) | +| **HashCloak** | Compressed Token & ZK Compression v2 | March '25 | [View](https://github.com/Lightprotocol/light-protocol/blob/main/audits/hashcloak_2025-03_compressed-token-update-and-zkcompression-v2.pdf) | +| **OtterSec** | Zerocopy | March '25 | [View](https://github.com/Lightprotocol/light-protocol/blob/main/audits/ottersec_2025-03_zerocopy.pdf) | +| **Accretion** | Compressed Token Program Update | January '25 | [View](https://github.com/Lightprotocol/light-protocol/blob/main/audits/accretion_2025-01_compressed-token-program-update.pdf) | +| **Zellic** | ZK Compression v1 | September '24 | [View](https://github.com/Lightprotocol/light-protocol/blob/main/audits/zellic_2024-09_zkcompression-v1.pdf) | +| **Neodyme** | ZK Compression v1 | August '24 | [View](https://github.com/Lightprotocol/light-protocol/blob/main/audits/neodyme_2024-08_zkcompression-v1.pdf) | +| **OtterSec** | ZK Compression v1 | August '24 | [View](https://github.com/Lightprotocol/light-protocol/blob/main/audits/ottersec_2024-08_zkcompression-v1.pdf) | ### Groth16 Circuit Security -The ZK Compression circuit was formally verified by Reilabs. See the report [here](https://github.com/Lightprotocol/light-protocol/blob/main/audits/reilabs_circuits_formal_verification_report.pdf). +The ZK Compression circuit was formally verified by Reilabs. See the report [here](https://github.com/Lightprotocol/light-protocol/blob/main/audits/reilabs_2024-08_circuits_formal_verification_report.pdf). Information about the Trusted Setup Ceremony for the groth16 circuits is [here](https://github.com/Lightprotocol/gnark-mt-setup/blob/main/README.md). diff --git a/references/terminology.mdx b/references/terminology.mdx index f97ab783..526cf15c 100644 --- a/references/terminology.mdx +++ b/references/terminology.mdx @@ -42,7 +42,8 @@ A set of [validators](https://solana.com/docs/references/terminology#validator) ## Compressed PDA -Compressed accounts at Program Derived Addresses. +Compressed accounts with an address stored in an address Merkle tree. +Full Solana PDA functionality and composability without rent-exemption. ## Compressed account @@ -56,25 +57,23 @@ A 32-byte identifier uniquely that represents a compressed account's state, stor An SPL token mint uniquely represents a token on the Solana network and stores global metadata about the token, including `mint_authority`, `supply`, and `decimals`. -SPL tokens can be compressed if the mint has an SPL Interface PDA set up. Anyone can create an SPL interface for any given SPL mint. +SPL tokens can be compressed if the mint has a token pool account set up. Anyone can create a token pool PDA for any given SPL mint. -## SPL Interface (omnibus account) +## SPL Interface PDA Account -An SPL token account (the SPL Interface PDA) that holds SPL tokens corresponding to compressed tokens in circulation. Tokens are deposited during compression and withdrawn during decompression; the account is owned by the Light Token Program's CPI authority PDA. - -## Concurrency - -The ability to process multiple Merkle tree update requests simultaneously without invalidating each other, as long as they don't modify the same leaf. - -Concurrency in ZK Compression allows parallel operations on different tree leaves without requiring locks. +SPL interface PDA account that holds SPL tokens corresponding to compressed tokens and Light Tokens in circulation. +Owned by the Light Token Program's CPI authority PDA. ## Compressed Token -An SPL token in compressed form. Compressed tokens do not require an associated token account per holder. +An SPL token in compressed form. +Compressed tokens do not require an associated token account per holder. ## Compressed Token account -An account type in the Light Token Program to store information about an individual's ownership of a specific token (mint). Compressed token accounts do not require a rent exempt balance upon creation. +An account type in the Light Token Program to store information about an individual's ownership of a specific token (mint). +Compressed token accounts do not require a rent exempt balance upon creation. +Compressed token accounts are compressed accounts that do not need an address. ## Light Token Program @@ -106,7 +105,7 @@ A call from one [program](https://solana.com/docs/core/transactions#onchain-prog ## Decompression -The process of converting a compressed to a regular Solana account. SPL tokens are withdrawn from the SPL Interface PDA to an Associated Token Account and compressed token accounts are invalidated. +The process of converting a compressed to a regular Solana account. SPL tokens are withdrawn from the token pool to an Associated Token Account and compressed token accounts are invalidated. ## Forester node / Forester diff --git a/snippets/code-snippets/light-token/transfer-interface/anchor-program/create-and-transfer-example.mdx b/snippets/code-snippets/light-token/transfer-interface/anchor-program/create-and-transfer-example.mdx new file mode 100644 index 00000000..868d48b6 --- /dev/null +++ b/snippets/code-snippets/light-token/transfer-interface/anchor-program/create-and-transfer-example.mdx @@ -0,0 +1,249 @@ + +```rust lib.rs +#![allow(unexpected_cfgs, deprecated)] + +use anchor_lang::prelude::*; +use light_sdk::interface::CreateAccountsProof; +use light_token::anchor::{derive_light_cpi_signer, light_program, CpiSigner, LightAccounts}; +use light_token::instruction::TransferInterfaceCpi; + +declare_id!("672fL1Nm191MbPoygNM9DRiG2psBELn97XUpGbU3jW7E"); + +pub const LIGHT_CPI_SIGNER: CpiSigner = + derive_light_cpi_signer!("672fL1Nm191MbPoygNM9DRiG2psBELn97XUpGbU3jW7E"); + +#[derive(AnchorSerialize, AnchorDeserialize, Clone)] +pub struct TransferParams { + pub create_accounts_proof: CreateAccountsProof, + pub dest_associated_token_account_bump: u8, + pub amount: u64, + pub decimals: u8, +} + +#[light_program] +#[program] +pub mod create_and_transfer { + use super::*; + + pub fn transfer<'info>( + ctx: Context<'_, '_, '_, 'info, Transfer<'info>>, + params: TransferParams, + ) -> Result<()> { + TransferInterfaceCpi::new( + params.amount, + params.decimals, + ctx.accounts.source.to_account_info(), + ctx.accounts.destination.to_account_info(), + ctx.accounts.authority.to_account_info(), + ctx.accounts.payer.to_account_info(), + ctx.accounts.light_token_cpi_authority.to_account_info(), + ctx.accounts.system_program.to_account_info(), + ) + .invoke() + .map_err(|e| anchor_lang::prelude::ProgramError::from(e))?; + Ok(()) + } +} + +#[derive(Accounts, LightAccounts)] +#[instruction(params: TransferParams)] +pub struct Transfer<'info> { + #[account(mut)] + pub payer: Signer<'info>, + + pub authority: Signer<'info>, + + /// CHECK: Validated by light-token CPI + pub mint: AccountInfo<'info>, + + /// CHECK: Validated by light-token CPI + #[account(mut)] + pub source: AccountInfo<'info>, + + /// CHECK: Validated by light-token CPI + pub recipient: AccountInfo<'info>, + + /// CHECK: Validated by light-token CPI + #[account(mut)] + #[light_account(init, + associated_token::authority = recipient, + associated_token::mint = mint, + associated_token::bump = params.dest_associated_token_account_bump + )] + pub destination: UncheckedAccount<'info>, + + /// CHECK: Validated by light-token CPI + pub light_token_program: AccountInfo<'info>, + + pub system_program: Program<'info, System>, + + /// CHECK: Validated by light-token CPI + pub light_token_compressible_config: AccountInfo<'info>, + + /// CHECK: Validated by light-token CPI + #[account(mut)] + pub rent_sponsor: AccountInfo<'info>, + + /// CHECK: Validated by light-token CPI + pub light_token_cpi_authority: AccountInfo<'info>, +} +``` + +```rust test.rs +use anchor_lang::{InstructionData, ToAccountMetas}; +use light_client::interface::{get_create_accounts_proof, InitializeRentFreeConfig}; +use light_program_test::{ + program_test::{setup_mock_program_data, LightProgramTest}, + Indexer, ProgramTestConfig, Rpc, +}; +use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; +use light_token::instruction::{ + derive_token_ata, find_mint_address, COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR, +}; +use solana_instruction::Instruction; +use solana_keypair::Keypair; +use solana_signer::Signer; +use create_and_transfer::{TransferParams, ID}; + +#[tokio::test] +async fn test_transfer() { + let config = ProgramTestConfig::new_v2(true, Some(vec![("create_and_transfer", ID)])) + .with_light_protocol_events(); + + let mut rpc = LightProgramTest::new(config).await.unwrap(); + let payer = rpc.get_payer().insecure_clone(); + + let program_data_pda = setup_mock_program_data(&mut rpc, &payer, &ID); + + let (init_config_ix, _config_pda) = InitializeRentFreeConfig::new( + &ID, + &payer.pubkey(), + &program_data_pda, + RENT_SPONSOR, + payer.pubkey(), + ) + .build(); + + rpc.create_and_send_transaction(&[init_config_ix], &payer.pubkey(), &[&payer]) + .await + .unwrap(); + + let (mint_pda, _mint_seed) = setup_create_mint( + &mut rpc, + &payer, + payer.pubkey(), // mint_authority + 9, // decimals + ) + .await; + + println!("Mint created at: {}", mint_pda); + + let sender = Keypair::new(); + let (sender_associated_token_account, _sender_associated_token_account_bump) = + derive_token_ata(&sender.pubkey(), &mint_pda); + + let create_sender_associated_token_account_ix = + light_token::instruction::CreateAssociatedTokenAccount::new( + payer.pubkey(), + sender.pubkey(), + mint_pda, + ) + .instruction() + .unwrap(); + + rpc.create_and_send_transaction( + &[create_sender_associated_token_account_ix], + &payer.pubkey(), + &[&payer], + ) + .await + .unwrap(); + + let mint_amount: u64 = 1_000_000_000; + mint_tokens(&mut rpc, &payer, mint_pda, sender_associated_token_account, mint_amount).await; + + println!( + "Minted {} tokens to sender: {}", + mint_amount, sender_associated_token_account + ); + + let recipient = Keypair::new(); + let (recipient_associated_token_account, recipient_associated_token_account_bump) = + derive_token_ata(&recipient.pubkey(), &mint_pda); + + let transfer_proof_result = get_create_accounts_proof(&rpc, &ID, vec![]).await.unwrap(); + + let transfer_accounts = create_and_transfer::accounts::Transfer { + payer: payer.pubkey(), + authority: sender.pubkey(), + mint: mint_pda, + source: sender_associated_token_account, + recipient: recipient.pubkey(), + destination: recipient_associated_token_account, + light_token_program: LIGHT_TOKEN_PROGRAM_ID.into(), + system_program: solana_sdk::system_program::ID, + light_token_compressible_config: COMPRESSIBLE_CONFIG_V1, + rent_sponsor: RENT_SPONSOR, + light_token_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), + }; + + let transfer_amount: u64 = 500_000_000; // 0.5 tokens + let decimals: u8 = 9; + + let transfer_ix = Instruction { + program_id: ID, + accounts: [ + transfer_accounts.to_account_metas(None), + transfer_proof_result.remaining_accounts, + ] + .concat(), + data: create_and_transfer::instruction::Transfer { + params: TransferParams { + create_accounts_proof: transfer_proof_result.create_accounts_proof, + dest_associated_token_account_bump: recipient_associated_token_account_bump, + amount: transfer_amount, + decimals, + }, + } + .data(), + }; + + let sig = rpc + .create_and_send_transaction(&[transfer_ix], &payer.pubkey(), &[&payer, &sender]) + .await + .unwrap(); + + println!("Transfer Tx: {}", sig); + + use light_token_interface::state::Token; + + let recipient_account = rpc + .get_account(recipient_associated_token_account) + .await + .unwrap() + .unwrap(); + let recipient_token: Token = + borsh::BorshDeserialize::deserialize(&mut &recipient_account.data[..]).unwrap(); + + assert_eq!(recipient_token.amount, transfer_amount); + assert_eq!(recipient_token.owner, recipient.pubkey().to_bytes()); + + println!( + "Recipient balance: {}, owner: {}", + recipient_token.amount, + recipient.pubkey() + ); + + let sender_account = rpc + .get_account(sender_associated_token_account) + .await + .unwrap() + .unwrap(); + let sender_token: Token = + borsh::BorshDeserialize::deserialize(&mut &sender_account.data[..]).unwrap(); + + assert_eq!(sender_token.amount, mint_amount - transfer_amount); + println!("Sender remaining balance: {}", sender_token.amount); +} +``` + \ No newline at end of file diff --git a/snippets/overview-tables/program-examples-table.mdx b/snippets/overview-tables/program-examples-table.mdx index 3a52e419..e736f453 100644 --- a/snippets/overview-tables/program-examples-table.mdx +++ b/snippets/overview-tables/program-examples-table.mdx @@ -8,7 +8,7 @@ | [Counter (Pinocchio)](https://github.com/Lightprotocol/program-examples/tree/main/counter/pinocchio) | Pinocchio implementation using light-sdk-pinocchio with Rust tests | | [Create-and-Update](https://github.com/Lightprotocol/program-examples/tree/main/create-and-update) | Create new compressed accounts and update existing ones within a single instruction and one validity proof | | [merkle-distributor](https://github.com/Lightprotocol/distributor) | SPL token distribution with compressed PDAs for claim tracking, vesting, and clawback | -| [Nullifier Program](https://github.com/Lightprotocol/nullifier-program) | System for payments and AI agents to prevent your onchain instruction from being executed more than once | +| [Nullifier Program](https://github.com/Lightprotocol/nullifier-program) | System for payments, AI agents and more to prevent your onchain instruction from being executed more than once | | [Read-Only](https://github.com/Lightprotocol/program-examples/tree/main/read-only) | Create compressed accounts and read them on-chain | | [simple-claim](https://github.com/Lightprotocol/program-examples-airdrop-implementations/tree/main/simple-claim) | Distributes compressed tokens that decompress to SPL on claim | | [ZK-ID](https://github.com/Lightprotocol/program-examples/tree/main/zk-id) | Zero-knowledge proofs for identity verification with compressed accounts | diff --git a/snippets/overview-tables/sdk-reference.mdx b/snippets/overview-tables/sdk-reference.mdx index ced6b237..09d94598 100644 --- a/snippets/overview-tables/sdk-reference.mdx +++ b/snippets/overview-tables/sdk-reference.mdx @@ -1,4 +1,4 @@ -### Client SDKs +### Client TypeScript token operations for Light Token and Compressed Tokens. - + Rust token operations for Light Token. From de358db452a83194c54c484a746e660c4ffba898 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Wed, 11 Feb 2026 01:47:14 +0000 Subject: [PATCH 10/27] move compressed token --- compressed-tokens/advanced-guides/airdrop.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/compressed-tokens/advanced-guides/airdrop.mdx b/compressed-tokens/advanced-guides/airdrop.mdx index 5a8778ab..53d4b9a6 100644 --- a/compressed-tokens/advanced-guides/airdrop.mdx +++ b/compressed-tokens/advanced-guides/airdrop.mdx @@ -1,5 +1,6 @@ --- title: Airdrop Guide +sidebarTitle: Token Distribution description: Complete client and program guides to create an airdrop – with or without code. ZK compression is the most efficient way to distribute SPL tokens. keywords: ["solana airdrop", "merkle distributor", "merkle airdrop", "airdrop infrastructure on solana", "scalable token distribution on solana", "token airdrop for protocols"] --- From 23de262507d704401109eb95fc033c34caedaed4 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Fri, 13 Feb 2026 02:19:11 +0000 Subject: [PATCH 11/27] add light pda --- .../guides/how-to-create-nullifier-pdas.mdx | 2 +- compressed-pdas/overview.mdx | 14 +- home.mdx | 2 +- light-token/light-pda.mdx | 197 +++++++++++++ resources/anchor-constraints.mdx | 194 +++++++++++++ .../counter/anchor-macro/full-example.mdx | 266 ++++++++++++++++++ 6 files changed, 670 insertions(+), 5 deletions(-) create mode 100644 light-token/light-pda.mdx create mode 100644 resources/anchor-constraints.mdx create mode 100644 snippets/code-snippets/light-token/counter/anchor-macro/full-example.mdx diff --git a/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx b/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx index c6a72025..40b23916 100644 --- a/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx +++ b/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx @@ -1,6 +1,6 @@ --- title: Create Nullifier PDAs -sidebarTitle: Nullifier PDAs +sidebarTitle: Nullifiers description: Create rent-free nullifier PDAs to prevent duplicate actions. keywords: ["nullifiers on solana", "prevent double spending", "compressed pdas", "rent-free nullifiers"] --- diff --git a/compressed-pdas/overview.mdx b/compressed-pdas/overview.mdx index a0ea81cd..fcf414e7 100644 --- a/compressed-pdas/overview.mdx +++ b/compressed-pdas/overview.mdx @@ -1,7 +1,7 @@ --- title: Overview & Program Template -description: Compressed PDAs provide full composability and functionality of accounts at PDAs, without rent-exemption per account. -keywords: ["rent free program derived addresses", "rent free pda accounts", "compressed pda on solana", "infrastructure for depins on solana", "scalable solana infrastructure", "stake accounts for depins", "cost efficient stake accounts", "scalable reward distribution on solana"] +description: To store user and app state, or other infrequently accessed state. Compressed PDAs provide full composability and functionality of accounts at PDAs, without rent-exemption per account. +keywords: ["user state", "app state", "node acounts", "depin accounts", "stake accounts", "not shared state or config or pool accounts", "rent free program derived addresses", "rent free pda accounts", "compressed pda on solana", "infrastructure for depins on solana", "scalable solana infrastructure", "stake accounts for depins", "cost efficient stake accounts", "scalable reward distribution on solana"] --- import ProgramExamplesTable from '/snippets/overview-tables/program-examples-table.mdx'; @@ -14,7 +14,15 @@ import SdkReferenceCompressedPdas from '/snippets/overview-tables/sdk-reference- | :------------- | :--------------------- | :---------------------- | | 100-byte PDA | ~1,600,000 lamports | 15,000 lamports | -Compressed PDAs are derived using a specific program address and seed, like regular PDAs. Custom programs invoke the Light System program to create and update accounts, instead of the System program. +Compressed PDAs are derived using a specific program address and seed, like regular PDAs. +Custom programs invoke the Light System program +to create and update compressed accounts, instead of the System program. +Compressed PDAs are compressed accounts with an address. + + +Use Compressed PDAs to store app and user state or other accounts that are infrequently accessed. +Do not use for shared state, pool accounts, or config accounts. + diff --git a/home.mdx b/home.mdx index 315e1414..c93c4494 100644 --- a/home.mdx +++ b/home.mdx @@ -117,7 +117,7 @@ while being more CU efficient than SPL on hot paths. ## Compressed PDA Toolkits - To store app and user state without rent-exemption. Introduction to compressed PDAs. + Introduction to compressed PDAs to store user, app, or other infrequently accessed state without rent-exemption. diff --git a/light-token/light-pda.mdx b/light-token/light-pda.mdx new file mode 100644 index 00000000..a1cc4505 --- /dev/null +++ b/light-token/light-pda.mdx @@ -0,0 +1,197 @@ +--- +title: "Light PDA" +sidebarTitle: "Integration Guide" +description: "Create PDA accounts with sponsored rent-exemption for Anchor programs. Works with your existing Anchor implementations." +--- + +import FullCounterExample from '/snippets/code-snippets/light-token/counter/anchor-macro/full-example.mdx'; + +Light-PDAs are Solana PDAs with sponsored rent-exemption. +Programs create them using Anchor `#[account(init)]` with `#[light_account(init)]`. + +| | Regular PDA | Light-PDA | +|------------------|----------------------|-----------------| +| 100-byte account | ~1,600,000 lamports | 10,000 lamports | + +## What changes + +| Area | Change | +|------|--------| +| State struct | Derive `LightAccount`, add `compression_info: CompressionInfo` | +| Accounts struct | Derive `LightAccounts`, add `#[light_account]` on init accounts | +| Program module | Add `#[light_program]` above `#[program]` | +| Instructions (reads, updates, closes) | No program changes. Client prepends a load instruction if account is cold. | + +Audit overhead is minimal as your program logic is mostly untouched. The rest is +macro-generated. + +--- + +## Step 1: Dependencies + +```toml +[dependencies] +light-account = { version = "0.20.0", features = ["anchor"] } +light-sdk = { version = "0.20.0", features = ["anchor", "v2", "cpi-context"] } +anchor-lang = "0.31" +``` + +## Step 2: State struct + +Add `compression_info` field and derive `LightAccount`: + +```rust +use light_account::{CompressionInfo, LightAccount}; + +#[derive(Default, Debug, InitSpace, LightAccount)] +#[account] +pub struct Counter { + /// Add this: + pub compression_info: CompressionInfo, + + pub owner: Pubkey, + pub count: u64, +} +``` + +## Step 3: Program module + +Add `#[light_program]` above `#[program]`. Define the CPI signer constant with your program ID: + +```rust +use light_account::{derive_light_cpi_signer, light_program, CpiSigner}; + +pub const LIGHT_CPI_SIGNER: CpiSigner = + derive_light_cpi_signer!("YourProgramId11111111111111111111111111111111"); + +#[light_program] +#[program] +pub mod counter { + use super::*; + + pub fn create_counter<'info>( + ctx: Context<'_, '_, '_, 'info, CreateCounter<'info>>, + params: CreateCounterParams, + ) -> Result<()> { + ctx.accounts.counter.owner = ctx.accounts.owner.key(); + ctx.accounts.counter.count = params.count; + Ok(()) + } + + /// Standard Anchor — no Light-specific changes. + pub fn increment(ctx: Context) -> Result<()> { + ctx.accounts.counter.count = ctx.accounts.counter.count.checked_add(1).unwrap(); + Ok(()) + } + + /// Standard Anchor — no Light-specific changes. + pub fn close_counter(_ctx: Context) -> Result<()> { + Ok(()) + } +} +``` + +## Step 4: Accounts struct + +Derive `LightAccounts` on your `Accounts` struct and add `#[light_account(...)]` next to `#[account(...)]`. + +Only the `init` struct derives `LightAccounts`. The increment and close structs +are standard Anchor: + +```rust +use light_account::{CreateAccountsProof, LightAccounts}; + +#[derive(AnchorSerialize, AnchorDeserialize, Clone)] +pub struct CreateCounterParams { + pub create_accounts_proof: CreateAccountsProof, + pub count: u64, +} + +#[derive(Accounts, LightAccounts)] +#[instruction(params: CreateCounterParams)] +pub struct CreateCounter<'info> { + #[account(mut)] + pub fee_payer: Signer<'info>, + + /// CHECK: Read-only, used for PDA derivation. + pub owner: AccountInfo<'info>, + + /// CHECK: Validated by Light Protocol CPI. + pub compression_config: AccountInfo<'info>, + + /// CHECK: PDA rent sponsor for compression rent reimbursement. + #[account(mut)] + pub pda_rent_sponsor: AccountInfo<'info>, + + #[account( + init, + payer = fee_payer, + space = 8 + ::INIT_SPACE, + seeds = [COUNTER_SEED, owner.key().as_ref()], + bump, + )] + #[light_account(init)] + pub counter: Account<'info, Counter>, + + pub system_program: Program<'info, System>, +} +``` + +## Full Example + + + + +View counter example on Github: [counter](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter) + + +--- + +## How it works + +The SDK pays the rent-exemption cost. After extended inactivity, cold accounts +auto-compress. Your program only ever interacts with hot accounts. Clients can +safely load cold accounts back into the onchain Solana account space when needed +via `create_load_instructions`. + +| | Hot (active) | Cold (inactive) | +|---|---|---| +| Storage | On-chain | Compressed | +| Latency/CU | No change | +load instruction | +| Your program code | No change | No change | + +## FAQ + + When creating an +account for the first time, the SDK provides a proof that the account doesn't +exist in the cold address space. The SVM already verifies this for the onchain +space. Both address spaces are checked before creation, preventing re-init +attacks, even if the account is currently cold. + + +Miners (Forester nodes) compress accounts that have been inactive for an extended period of time (when their virtual rent balance drops below threshold). +In practice, having to load cold accounts should be rare. The common path (hot) has no extra overhead and does not increase CU or txn size. + + + +When accounts compress after extended inactivity, the on-chain rent-exemption is released back +to the rent sponsor. This creates a revolving lifecycle: active "hot" accounts hold a +rent-exempt lamports balance, inactive "cold" accounts release it back. The +rent sponsor must be derived from the program owner. For all mint, ATA, and +token accounts, the Light Token Program is the rent sponsor. For your own program-owned PDAs, the SDK derives a rent sponsor address automatically. + + + +**Hot path (e.g. reads, updates, closes):** No. Active accounts do not add CU overhead to your instructions. + +**First time init + loading cold accounts:** Yes, adds up to 15k-400k CU, +depending on number and type of accounts being initialized or loaded. + + +--- + + +API is in Beta and subject to change. + +Questions or need hands-on support? [Telegram](https://t.me/swen_light) | [email](mailto:support@lightprotocol.com) | [Discord](https://discord.com/invite/7cJ8BhAXhu) + diff --git a/resources/anchor-constraints.mdx b/resources/anchor-constraints.mdx new file mode 100644 index 00000000..cbb19cca --- /dev/null +++ b/resources/anchor-constraints.mdx @@ -0,0 +1,194 @@ +--- +title: "Anchor Constraints LightAccount" +description: "Syntax reference for #[light_account] constraints with sponsored rent-exemption." +--- + +- [`#[light_account(init)]`](#light_accountinit) creates a PDA +- [`#[light_account(init, token::...)]`](#light_accountinit-token) creates a token account via CPI +- [`#[light_account(init, associated_token::...)]`](#light_accountinit-associated_token) creates an ATA via CPI +- [`#[light_account(init, mint::...)]`](#light_accountinit-mint) creates a mint via CPI +- [Required accounts](#required-accounts) per account type + +Place `#[light_account]` below standard Anchor `#[account]` on the same field. +Anchor handles seeds, space, and payer; LightAccount handles rent-free creation. + +--- + +### `#[light_account(init)]` + +Creates a rent-free PDA. No additional parameters — uses Anchor `#[account]` seeds and space. + +**attribute** + +``` +#[light_account(init)] +``` + +```rust +#[account( // ← Anchor: seeds, space, payer + init, + payer = fee_payer, + space = 8 + ::INIT_SPACE, + seeds = [COUNTER_SEED, owner.key().as_ref()], + bump, +)] +#[light_account(init)] // ← Light: register for rent-free creation +pub counter: Account<'info, Counter>, +``` + +Examples: [Github](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter) + +--- + +### `#[light_account(init, token::...)]` + +Creates a rent-free token account via CPI to the Light Token program. The account type is `UncheckedAccount` because Light Token program initializes it via CPI. + +**attribute** + +``` +#[light_account(init, + token::authority = , + token::mint = , + token::owner = , + token::bump = +)] +``` + +```rust +#[account( + mut, + seeds = [VAULT_SEED, mint.key().as_ref()], + bump, +)] +#[light_account(init, + token::authority = [VAULT_SEED, self.mint.key()], + token::mint = mint, + token::owner = vault_authority, + token::bump = params.vault_bump +)] +pub vault: UncheckedAccount<'info>, +``` + +Examples: [Github](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-token-account) + +--- + +### `#[light_account(init, associated_token::...)]` + +Creates a rent-free associated token account via CPI. + +**attribute** + +``` +#[light_account(init, + associated_token::authority = , + associated_token::mint = , + associated_token::bump = +)] +``` + +```rust +#[account(mut)] +#[light_account(init, + associated_token::authority = associated_token_account_owner, + associated_token::mint = associated_token_account_mint, + associated_token::bump = params.associated_token_account_bump +)] +pub associated_token_account: UncheckedAccount<'info>, +``` + +Examples: [Github](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-associated-token-account) + +--- + +### `#[light_account(init, mint::...)]` + +Creates a rent-free mint via CPI. + +**attribute (required)** + +``` +#[light_account(init, mint, + mint::signer = , + mint::authority = , + mint::decimals = , + mint::seeds = , +)] +``` + +**attribute (optional)** + +``` +mint::bump = +mint::freeze_authority = +mint::authority_seeds = +mint::name = // requires symbol + uri +mint::symbol = // requires name + uri +mint::uri = // requires name + symbol +mint::update_authority = // requires name, symbol, uri +mint::additional_metadata = // requires name, symbol, uri +``` + +```rust +#[account(mut)] +#[light_account(init, mint, + mint::signer = mint_signer, + mint::authority = fee_payer, + mint::decimals = 9, + mint::seeds = &[MINT_SIGNER_SEED, self.authority.to_account_info().key.as_ref()], +)] +pub mint: UncheckedAccount<'info>, +``` + + + +```rust +#[account(mut)] +#[light_account(init, mint, + mint::signer = mint_signer, + mint::authority = fee_payer, + mint::decimals = 9, + mint::seeds = &[MINT_SIGNER_SEED, self.authority.to_account_info().key.as_ref()], + mint::bump = params.mint_signer_bump, + mint::name = params.name.clone(), + mint::symbol = params.symbol.clone(), + mint::uri = params.uri.clone(), + mint::update_authority = authority, + mint::additional_metadata = params.additional_metadata.clone() +)] +pub mint: UncheckedAccount<'info>, +``` + + + +Examples: [Github](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-mint) + +--- + +## Required accounts + +Add these to your `init` struct alongside the fields above. The `LightAccounts` derive macro appends additional protocol accounts to the instruction at runtime — you don't add those manually. + + + + +| Account | Description | +|:-|:-| +| `compression_config` | Per-program PDA. Stores rent sponsor address and compression settings. Initialize once via `InitializeRentFreeConfig`. | +| `pda_rent_sponsor` | Per-program PDA. Receives rent-exemption lamports when accounts compress. Must be mutable. | +| `system_program` | Solana System Program. Transfers lamports for rent-exemption. | + + + + +| Account | Description | +|:-|:-| +| `light_token_compressible_config` | Protocol PDA. Stores rent-config for Light Token accounts. | +| `light_token_rent_sponsor` | Protocol PDA. Holds the lamport pool that sponsors rent-exemption. Reclaims lamports when accounts compress. | +| `light_token_program` | Light Token program. CPI target for token, ATA, and mint creation. | +| `light_token_cpi_authority` | Signer PDA. Authorizes CPI calls from your program to the Light Token program. | +| `system_program` | Solana System Program. Transfers lamports for rent-exemption. | + + + \ No newline at end of file diff --git a/snippets/code-snippets/light-token/counter/anchor-macro/full-example.mdx b/snippets/code-snippets/light-token/counter/anchor-macro/full-example.mdx new file mode 100644 index 00000000..dd4680f2 --- /dev/null +++ b/snippets/code-snippets/light-token/counter/anchor-macro/full-example.mdx @@ -0,0 +1,266 @@ + + + +```rust lib.rs expandable +use anchor_lang::prelude::*; +use light_account::{ + CompressionInfo, LightAccount, LightAccounts, CreateAccountsProof, + derive_light_cpi_signer, light_program, CpiSigner, +}; + +declare_id!("YourProgramId11111111111111111111111111111111"); + +pub const LIGHT_CPI_SIGNER: CpiSigner = + derive_light_cpi_signer!("YourProgramId11111111111111111111111111111111"); + +pub const COUNTER_SEED: &[u8] = b"counter"; + +#[derive(Default, Debug, InitSpace, LightAccount)] +#[account] +pub struct Counter { + pub compression_info: CompressionInfo, + pub owner: Pubkey, + pub count: u64, +} + +#[derive(AnchorSerialize, AnchorDeserialize, Clone)] +pub struct CreateCounterParams { + pub create_accounts_proof: CreateAccountsProof, + pub count: u64, +} + +#[light_program] +#[program] +pub mod counter { + use super::*; + + pub fn create_counter<'info>( + ctx: Context<'_, '_, '_, 'info, CreateCounter<'info>>, + params: CreateCounterParams, + ) -> Result<()> { + ctx.accounts.counter.owner = ctx.accounts.owner.key(); + ctx.accounts.counter.count = params.count; + Ok(()) + } + + /// Standard Anchor — no Light-specific changes. + pub fn increment(ctx: Context) -> Result<()> { + ctx.accounts.counter.count = ctx.accounts.counter.count.checked_add(1).unwrap(); + Ok(()) + } + + /// Standard Anchor — no Light-specific changes. + pub fn close_counter(_ctx: Context) -> Result<()> { + Ok(()) + } +} + +#[derive(Accounts, LightAccounts)] +#[instruction(params: CreateCounterParams)] +pub struct CreateCounter<'info> { + #[account(mut)] + pub fee_payer: Signer<'info>, + + /// CHECK: Read-only, used for PDA derivation. + pub owner: AccountInfo<'info>, + + /// CHECK: Validated by Light Protocol CPI. + pub compression_config: AccountInfo<'info>, + + /// CHECK: PDA rent sponsor for compression rent reimbursement. + #[account(mut)] + pub pda_rent_sponsor: AccountInfo<'info>, + + #[account( + init, + payer = fee_payer, + space = 8 + ::INIT_SPACE, + seeds = [COUNTER_SEED, owner.key().as_ref()], + bump, + )] + #[light_account(init)] + pub counter: Account<'info, Counter>, + + pub system_program: Program<'info, System>, +} + +/// Standard Anchor +#[derive(Accounts)] +pub struct Increment<'info> { + pub owner: Signer<'info>, + + #[account( + mut, + seeds = [COUNTER_SEED, owner.key().as_ref()], + bump, + has_one = owner, + )] + pub counter: Account<'info, Counter>, +} + +/// Standard Anchor close +#[derive(Accounts)] +pub struct CloseCounter<'info> { + #[account(mut)] + pub fee_payer: Signer<'info>, + + pub owner: Signer<'info>, + + #[account( + mut, + close = fee_payer, + seeds = [COUNTER_SEED, owner.key().as_ref()], + bump, + has_one = owner, + )] + pub counter: Account<'info, Counter>, +} +``` + + + + +```rust counter.rs expandable +//! Light-PDA lifecycle test: create → increment → close. + +use anchor_lang::{InstructionData, ToAccountMetas}; +use light_client::interface::{ + get_create_accounts_proof, CreateAccountsProofInput, InitializeRentFreeConfig, +}; +use light_program_test::{ + program_test::{setup_mock_program_data, LightProgramTest}, + ProgramTestConfig, Rpc, +}; +use light_token::instruction::RENT_SPONSOR; +use solana_instruction::Instruction; +use solana_keypair::Keypair; +use solana_pubkey::Pubkey; +use solana_signer::Signer; + +const PROGRAM_ID: Pubkey = counter::ID; + +/// Setup: create test RPC and initialize rent-free config for the counter program. +async fn setup() -> (LightProgramTest, Keypair, Pubkey) { + let config = ProgramTestConfig::new_v2(true, Some(vec![("counter", PROGRAM_ID)])); + let mut rpc = LightProgramTest::new(config).await.unwrap(); + let payer = rpc.get_payer().insecure_clone(); + + let program_data_pda = setup_mock_program_data(&mut rpc, &payer, &PROGRAM_ID); + + // Register this program for rent-free accounts. One-time setup per program. + let (init_config_ix, compression_config) = InitializeRentFreeConfig::new( + &PROGRAM_ID, + &payer.pubkey(), + &program_data_pda, + RENT_SPONSOR, + payer.pubkey(), + ) + .build(); + + rpc.create_and_send_transaction(&[init_config_ix], &payer.pubkey(), &[&payer]) + .await + .expect("initialize rent-free config"); + + (rpc, payer, compression_config) +} + +#[tokio::test] +async fn test_counter_lifecycle() { + let (mut rpc, payer, compression_config) = setup().await; + + // ── Create ─────────────────────────────────────────────────────────── + let (counter_pda, _) = Pubkey::find_program_address( + &[counter::COUNTER_SEED, payer.pubkey().as_ref()], + &PROGRAM_ID, + ); + + let proof_result = get_create_accounts_proof( + &rpc, + &PROGRAM_ID, + vec![CreateAccountsProofInput::pda(counter_pda)], + ) + .await + .unwrap(); + + let create_accounts = counter::accounts::CreateCounter { + fee_payer: payer.pubkey(), + owner: payer.pubkey(), + compression_config, + counter: counter_pda, + system_program: solana_sdk::system_program::ID, + }; + + let create_data = counter::instruction::CreateCounter { + params: counter::CreateCounterParams { + create_accounts_proof: proof_result.create_accounts_proof, + count: 0, + }, + }; + + let create_ix = Instruction { + program_id: PROGRAM_ID, + accounts: [ + create_accounts.to_account_metas(None), + proof_result.remaining_accounts, + ] + .concat(), + data: create_data.data(), + }; + + rpc.create_and_send_transaction(&[create_ix], &payer.pubkey(), &[&payer]) + .await + .expect("create_counter"); + + // Verify initial state. + let account = rpc.get_account(counter_pda).await.unwrap().unwrap(); + let ctr: counter::Counter = + anchor_lang::AccountDeserialize::try_deserialize(&mut account.data.as_slice()).unwrap(); + assert_eq!(ctr.count, 0); + assert_eq!(ctr.owner, payer.pubkey()); + + // ── Increment (standard Anchor) ──────────────────────────── + let inc_accounts = counter::accounts::Increment { + owner: payer.pubkey(), + counter: counter_pda, + }; + let inc_data = counter::instruction::Increment {}; + let inc_ix = Instruction { + program_id: PROGRAM_ID, + accounts: inc_accounts.to_account_metas(None), + data: inc_data.data(), + }; + + rpc.create_and_send_transaction(&[inc_ix], &payer.pubkey(), &[&payer]) + .await + .expect("increment"); + + let account = rpc.get_account(counter_pda).await.unwrap().unwrap(); + let ctr: counter::Counter = + anchor_lang::AccountDeserialize::try_deserialize(&mut account.data.as_slice()).unwrap(); + assert_eq!(ctr.count, 1); + + // ── Close (standard Anchor) ──────────────────────────────── + let close_accounts = counter::accounts::CloseCounter { + fee_payer: payer.pubkey(), + owner: payer.pubkey(), + counter: counter_pda, + }; + let close_data = counter::instruction::CloseCounter {}; + let close_ix = Instruction { + program_id: PROGRAM_ID, + accounts: close_accounts.to_account_metas(None), + data: close_data.data(), + }; + + rpc.create_and_send_transaction(&[close_ix], &payer.pubkey(), &[&payer]) + .await + .expect("close_counter"); + + // Account should no longer exist. + let account = rpc.get_account(counter_pda).await.unwrap(); + assert!(account.is_none(), "counter should be closed"); +} +``` + + + From cc5bd80887cfd171935c3e45bbc8ce655d48f5b9 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Fri, 13 Feb 2026 16:10:55 +0000 Subject: [PATCH 12/27] update rpc + home + terminology --- api-reference/json-rpc-methods/methods.mdx | 100 --- api-reference/json-rpc-methods/overview.mdx | 207 ++++-- compressed-tokens/advanced-guides.mdx | 9 - ...d-wallet-support-for-compressed-tokens.mdx | 640 ------------------ .../example-token-distribution.mdx | 8 - ...-combine-operations-in-one-transaction.mdx | 198 ------ .../use-token-2022-with-compression.mdx | 277 -------- .../{advanced-guides => }/airdrop.mdx | 0 compressed-tokens/guides.mdx | 9 - .../add-token-pools-to-mint-accounts.mdx | 111 --- .../guides/compress-decompress.mdx | 217 ------ .../guides/compress-spl-token-account.mdx | 189 ------ .../create-compressed-token-accounts.mdx | 20 - .../guides/create-mint-with-token-pool.mdx | 99 --- compressed-tokens/guides/delegate.mdx | 166 ----- .../merge-compressed-token-accounts.mdx | 145 ---- .../guides/mint-compressed-tokens.mdx | 154 ----- .../guides/transfer-compressed-tokens.mdx | 190 ------ compressed-tokens/overview.mdx | 55 +- home.mdx | 33 +- light-token/light-pda.mdx | 3 +- light-token/pda-overview.mdx | 44 ++ references/terminology.mdx | 251 ++++--- ...ompressed-tokens-advanced-guides-table.mdx | 2 +- 24 files changed, 397 insertions(+), 2730 deletions(-) delete mode 100644 api-reference/json-rpc-methods/methods.mdx delete mode 100644 compressed-tokens/advanced-guides.mdx delete mode 100644 compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens.mdx delete mode 100644 compressed-tokens/advanced-guides/example-token-distribution.mdx delete mode 100644 compressed-tokens/advanced-guides/how-to-combine-operations-in-one-transaction.mdx delete mode 100644 compressed-tokens/advanced-guides/use-token-2022-with-compression.mdx rename compressed-tokens/{advanced-guides => }/airdrop.mdx (100%) delete mode 100644 compressed-tokens/guides.mdx delete mode 100644 compressed-tokens/guides/add-token-pools-to-mint-accounts.mdx delete mode 100644 compressed-tokens/guides/compress-decompress.mdx delete mode 100644 compressed-tokens/guides/compress-spl-token-account.mdx delete mode 100644 compressed-tokens/guides/create-compressed-token-accounts.mdx delete mode 100644 compressed-tokens/guides/create-mint-with-token-pool.mdx delete mode 100644 compressed-tokens/guides/delegate.mdx delete mode 100644 compressed-tokens/guides/merge-compressed-token-accounts.mdx delete mode 100644 compressed-tokens/guides/mint-compressed-tokens.mdx delete mode 100644 compressed-tokens/guides/transfer-compressed-tokens.mdx create mode 100644 light-token/pda-overview.mdx diff --git a/api-reference/json-rpc-methods/methods.mdx b/api-reference/json-rpc-methods/methods.mdx deleted file mode 100644 index 67124992..00000000 --- a/api-reference/json-rpc-methods/methods.mdx +++ /dev/null @@ -1,100 +0,0 @@ ---- -title: JSON RPC Methods -description: Reference to all JSON RPC endpoints for ZK Compression on Solana. -sidebarTitle: "Overview" ---- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[GetCompressedAccount](/api-reference/json-rpc-methods/getcompressedaccount)Retrieves information about a specific compressed account by its address or hash.
[GetCompressedAccountsByOwner](/api-reference/json-rpc-methods/getcompressedaccountsbyowner)Returns all compressed accounts owned by a specific address.
[GetCompressedBalance](/api-reference/json-rpc-methods/getcompressedbalance)Retrieves the balance of a compressed account.
[GetCompressedBalanceByOwner](/api-reference/json-rpc-methods/getcompressedbalancebyowner)Gets the total balance of all compressed accounts owned by an address.
[GetCompressedMintTokenHolders](/api-reference/json-rpc-methods/getcompressedminttokenholders)Lists all holders of a specific compressed token mint.
[GetCompressedTokenAccountBalance](/api-reference/json-rpc-methods/getcompressedtokenaccountbalance)Retrieves the token balance of a compressed token account.
[GetCompressedTokenAccountsByDelegate](/api-reference/json-rpc-methods/getcompressedtokenaccountbydelegate)Returns all compressed token accounts delegated to a specific address.
[GetCompressedTokenAccountsByOwner](/api-reference/json-rpc-methods/getcompressedtokenaccountsbyowner)Lists all compressed token accounts owned by a specific address.
[GetCompressedTokenBalancesByOwner](/api-reference/json-rpc-methods/getcompressedtokenbalancesbyowner)Retrieves all token balances for compressed accounts owned by an address.
[GetCompressionSignaturesForAccount](/api-reference/json-rpc-methods/getcompressionsignaturesforaccount)Returns signatures for transactions involving a compressed account.
[GetCompressionSignaturesForAddress](/api-reference/json-rpc-methods/getcompressionsignaturesforaddress)Retrieves signatures for transactions involving a specific address.
[GetCompressionSignaturesForOwner](/api-reference/json-rpc-methods/getcompressionsignaturesforowner)Returns signatures for transactions where an address is the owner.
[GetCompressionSignaturesForTokenOwner](/api-reference/json-rpc-methods/getcompressionsignaturesfortokenowner)Lists signatures for transactions involving tokens owned by an address.
[GetIndexerHealth](/api-reference/json-rpc-methods/getindexerhealth)Returns the health status of the compression indexer.
[GetIndexerSlot](/api-reference/json-rpc-methods/getindexerslot)Retrieves the current slot of the compression indexer.
[GetLatestCompressionSignatures](/api-reference/json-rpc-methods/getlatestcompressionsignatures)Returns the most recent transaction signatures related to compression.
[GetLatestNon-VotingSignatures](/api-reference/json-rpc-methods/getlatestnonvotingsignatures)Retrieves recent non-voting transaction signatures.
[GetMultipleCompressedAccounts](/api-reference/json-rpc-methods/getmultiplecompressedaccounts)Retrieves multiple compressed accounts in a single request.
[GetMultipleNewAddressProofs](/api-reference/json-rpc-methods/getmultiplenewaddressproofs)Returns proofs that the new addresses are not taken already and can be created.
[GetTransactionWithCompressionInfo](/api-reference/json-rpc-methods/gettransactionwithcompressioninfo)Returns transaction details with additional compression-related information.
[GetValidityProof](/api-reference/json-rpc-methods/getvalidityproof)Retrieves a validity proof for compressed data.
diff --git a/api-reference/json-rpc-methods/overview.mdx b/api-reference/json-rpc-methods/overview.mdx index 288dab49..9043baf4 100644 --- a/api-reference/json-rpc-methods/overview.mdx +++ b/api-reference/json-rpc-methods/overview.mdx @@ -1,27 +1,35 @@ --- title: JSON RPC Methods -description: Overview JSON RPC endpoints on Solana, best practices, and error codes. +description: Photon indexer methods for querying compressed state on Solana. sidebarTitle: "Overview" --- -The API exposed by the indexer closely mirrors existing RPC calls, with one-to-one mapping: + +The Light Token SDK calls these methods internally via interface functions +like `transferInterface` and `getAtaInterface`. You rarely need to call +them directly. -| Solana RPC | Photon RPC Calls | -| :---------------------- | :------------------------------- | -| getAccountInfo | getCompressedAccount | -| getBalance | getCompressedBalance | -| getTokenAccountsByOwner | getCompressedTokenAccountsByOwner | -| getProgramAccounts | getCompressedAccountsByOwner | +Call these methods directly if you are building a block explorer, +custom indexer, or working with +[legacy compressed tokens](/compressed-tokens/overview). + - +The Light Token SDK exposes interface methods that check both hot (on-chain) and cold (compressed) state: -## Create an RPC Connection +| Light SDK interface method | Solana RPC | Photon RPC | +| :-------------------------------- | :---------------------- | :-------------------------------- | +| `getAccountInfoInterface` | getAccountInfo | getCompressedAccount | +| `getBalanceInterface` | getBalance | getCompressedBalanceByOwner | +| `getAtaInterface` | getAccountInfo | getCompressedTokenAccountsByOwner | +| `getTokenAccountBalanceInterface` | getTokenAccountBalance | getCompressedTokenBalancesByOwner | +| `getSignaturesForAddressInterface`| getSignaturesForAddress | getCompressionSignaturesForAddress| +| `getSignaturesForOwnerInterface` | getSignaturesForAddress | getCompressionSignaturesForOwner | + +Each interface method executes both calls in parallel and merges the results. + + + +## Create an RPC connection @@ -29,7 +37,7 @@ The API exposed by the indexer closely mirrors existing RPC calls, with one-to-o // Helius exposes Solana and Photon RPC endpoints through a single URL import { createRpc, Rpc } from '@lightprotocol/stateless.js'; -const RPC_ENDPOINT = ''; +const RPC_ENDPOINT = 'https://mainnet.helius-rpc.com?api-key=YOUR_KEY'; const connection: Rpc = createRpc(RPC_ENDPOINT, RPC_ENDPOINT); ``` @@ -45,41 +53,138 @@ const connection: Rpc = createRpc(RPC_ENDPOINT, RPC_ENDPOINT); -## Best Practices - -| Best Practice | Description | -|:----------------------|:----------------------------------------------------------------------------------------------------------------| -| **Commitment Levels**| Use appropriate commitment levels: `processed` (fastest), `confirmed` (balanced), `finalized` (most reliable) | -| **Rate Limiting** | Implement retry logic and respect rate limits. Public endpoints: 100 req/s, Private: 1000+ req/s | -| **Batch Requests** | Use batch requests when possible to improve efficiency and reduce API calls | -| **Caching** | Cache frequently accessed data to reduce API calls and improve performance | +## Best practices -## Error Codes +| Best practice | Description | +|:-----------------------|:---------------------------------------------------------------------------------------------------------------| +| **Commitment levels** | Use appropriate commitment levels: `processed` (fastest), `confirmed` (balanced), `finalized` (most reliable). | +| **Rate limiting** | Implement retry logic and respect rate limits. Public endpoints: 100 req/s, Private: 1000+ req/s. | +| **Batch requests** | Use batch requests when possible to reduce API calls. | +| **Caching** | Cache frequently accessed data to reduce API calls. | - -
- For help with debugging use - - Ask DeepWiki - -
-
+## Error codes | Code | Message | Description | -| :------ | :-------------------- | :-------------------------------------------- | -| -32600 | Invalid Request | The JSON sent is not a valid Request object | -| -32601 | Method not found | The method does not exist / is not available | -| -32602 | Invalid params | Invalid method parameter(s) | -| -32603 | Internal error | Internal JSON-RPC error | -| -32000 | Account not found | The compressed account was not found | -| -32001 | Invalid account hash | The provided account hash is invalid | - -# Next Steps - - +| :----- | :------------------- | :------------------------------------------- | +| -32600 | Invalid Request | The JSON sent is not a valid Request object. | +| -32601 | Method not found | The method does not exist / is not available. | +| -32602 | Invalid params | Invalid method parameter(s). | +| -32603 | Internal error | Internal JSON-RPC error. | +| -32000 | Account not found | The compressed account was not found. | +| -32001 | Invalid account hash | The provided account hash is invalid. | + +## Methods + +These methods are called internally by the Light Token SDK. Call them +directly for custom indexing, block explorers, or debugging. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[GetCompressedAccount](/api-reference/json-rpc-methods/getcompressedaccount)Returns a compressed account by address or hash.
[GetCompressedAccountsByOwner](/api-reference/json-rpc-methods/getcompressedaccountsbyowner)Returns all compressed accounts for an owner.
[GetCompressedBalanceByOwner](/api-reference/json-rpc-methods/getcompressedbalancebyowner)Returns the total compressed balance for an owner.
[GetCompressedTokenAccountsByOwner](/api-reference/json-rpc-methods/getcompressedtokenaccountsbyowner)Returns all compressed token accounts for an owner.
[GetCompressedTokenBalancesByOwner](/api-reference/json-rpc-methods/getcompressedtokenbalancesbyowner)Returns all token balances for compressed accounts owned by an address.
[GetValidityProof](/api-reference/json-rpc-methods/getvalidityproof)Returns a validity proof for compressed state transitions.
[GetCompressionSignaturesForAddress](/api-reference/json-rpc-methods/getcompressionsignaturesforaddress)Returns signatures for transactions involving an address.
[GetCompressionSignaturesForOwner](/api-reference/json-rpc-methods/getcompressionsignaturesforowner)Returns signatures for transactions where an address is the owner.
[GetTransactionWithCompressionInfo](/api-reference/json-rpc-methods/gettransactionwithcompressioninfo)Returns transaction details with compression context.
[GetIndexerHealth](/api-reference/json-rpc-methods/getindexerhealth)Returns the health status of the Photon indexer.
[GetIndexerSlot](/api-reference/json-rpc-methods/getindexerslot)Returns the current slot of the Photon indexer.
+ +## Legacy + +Methods for direct compressed-token workflows. Not called by the Light +Token SDK interface functions. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
[GetCompressedBalance](/api-reference/json-rpc-methods/getcompressedbalance)Returns the balance of a single compressed account.
[GetCompressedMintTokenHolders](/api-reference/json-rpc-methods/getcompressedminttokenholders)Lists all holders of a compressed token mint.
[GetCompressedTokenAccountBalance](/api-reference/json-rpc-methods/getcompressedtokenaccountbalance)Returns the token balance of a single compressed token account.
[GetCompressedTokenAccountsByDelegate](/api-reference/json-rpc-methods/getcompressedtokenaccountbydelegate)Returns all compressed token accounts delegated to an address.
[GetCompressionSignaturesForAccount](/api-reference/json-rpc-methods/getcompressionsignaturesforaccount)Returns signatures for transactions involving a compressed account.
[GetCompressionSignaturesForTokenOwner](/api-reference/json-rpc-methods/getcompressionsignaturesfortokenowner)Returns signatures for token transactions by owner.
[GetLatestCompressionSignatures](/api-reference/json-rpc-methods/getlatestcompressionsignatures)Returns the most recent compression-related signatures.
[GetLatestNonVotingSignatures](/api-reference/json-rpc-methods/getlatestnonvotingsignatures)Returns recent non-voting transaction signatures.
[GetMultipleCompressedAccounts](/api-reference/json-rpc-methods/getmultiplecompressedaccounts)Returns multiple compressed accounts in a single request.
[GetMultipleNewAddressProofs](/api-reference/json-rpc-methods/getmultiplenewaddressproofs)Returns proofs that new addresses can be created.
\ No newline at end of file diff --git a/compressed-tokens/advanced-guides.mdx b/compressed-tokens/advanced-guides.mdx deleted file mode 100644 index 94066669..00000000 --- a/compressed-tokens/advanced-guides.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: Advanced Guides -description: "Reference table to advanced guides. Includes guides for airdrops, using token-2022, wallet support for compressed tokens, and client examples." -sidebarTitle: "Overview" ---- - -import AdvancedGuidesTable from '/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx'; - - diff --git a/compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens.mdx b/compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens.mdx deleted file mode 100644 index 8f7c9112..00000000 --- a/compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens.mdx +++ /dev/null @@ -1,640 +0,0 @@ ---- -title: Add Wallet Support for Compressed Tokens -description: Guide to add Compressed Token Support to Your Wallet Application -keywords: ["wallet integration compressed tokens", "wallet infrastructure on solana"] ---- - -import InstallDependencies from '/snippets/setup/install-dependencies-codegroup.mdx'; -import SetupEnvironment from '/snippets/setup/setup-environment-tabs.mdx'; - - -Leading Solana Wallets like Phantom and Backpack already support compressed tokens. - - -# Integration Steps - - - - -### Display Compressed Token Balances - -```javascript -import { Rpc, createRpc } from '@lightprotocol/stateless.js'; -import { PublicKey } from '@solana/web3.js'; - -const connection: Rpc = createRpc(); -const publicKey = new PublicKey('FWwR2s4TwpWN3nkCzVfhuPrpePG8kNzBXAxEbNsaDFNu'); - -(async () => { - const balances = await connection.getCompressedTokenBalancesByOwnerV2(publicKey); - - if (balances.value.items.length === 0) { - console.log("No compressed token balances found"); - return; - } - - for (const item of balances.value.items) { - const balanceValue = typeof item.balance === 'string' - ? parseInt(item.balance, 16) - : item.balance; - - const mintInfo = await connection.getAccountInfo(new PublicKey(item.mint)); - const decimals = mintInfo.data[44]; - const formattedBalance = balanceValue / Math.pow(10, decimals); - - console.log(`Mint: ${item.mint}`); - console.log(`Balance: ${formattedBalance} tokens\n`); - } -})(); -``` - -### Get Transaction History - -```typescript -import { Rpc, createRpc } from '@lightprotocol/stateless.js'; -import { PublicKey } from '@solana/web3.js'; - -const connection: Rpc = createRpc(); -const publicKey = new PublicKey('FWwR2s4TwpWN3nkCzVfhuPrpePG8kNzBXAxEbNsaDFNu'); - -(async () => { - const signatures = await connection.getCompressionSignaturesForTokenOwner(publicKey); - - if (signatures.items.length > 0) { - console.log(`Signatures:`); - signatures.items.forEach((sig, index) => { - console.log(`${index + 1}. ${sig.signature}`); - console.log(` Slot: ${sig.slot}`); - console.log(` Time: ${new Date(sig.blockTime * 1000).toISOString()}`); - }); - } else { - console.log("No transactions found"); - } -})(); -``` - - - -```typescript -import { Rpc, createRpc } from '@lightprotocol/stateless.js'; -import { PublicKey } from '@solana/web3.js'; - -const RPC_ENDPOINT = process.env.RPC_ENDPOINT || 'https://devnet.helius-rpc.com?api-key='; - -const connection: Rpc = createRpc(RPC_ENDPOINT, RPC_ENDPOINT); -const publicKey = new PublicKey('FWwR2s4TwpWN3nkCzVfhuPrpePG8kNzBXAxEbNsaDFNu'); - -(async () => { - try { - const signatures = await connection.getCompressionSignaturesForTokenOwner(publicKey); - - if (signatures.items.length === 0) { - console.log("No transactions found"); - return; - } - - console.log(`Latest Transaction:`); - console.log(`Signature: ${signatures.items[0].signature}`); - console.log(`Slot: ${signatures.items[0].slot}`); - - const txInfo = await connection.getTransactionWithCompressionInfo(signatures.items[0].signature); - - if (!txInfo) { - console.log('Transaction not found or has no compression info'); - return; - } - - if (txInfo.compressionInfo) { - console.log(`\nClosed Accounts: ${txInfo.compressionInfo.closedAccounts.length}`); - console.log(`Opened Accounts: ${txInfo.compressionInfo.openedAccounts.length}`); - } - } catch (error) { - console.error('Error fetching transaction history:', error); - } -})(); -``` - - - -### Send Compressed Tokens - -```typescript expandable -import { - Rpc, - createRpc, - bn, - dedupeSigner, - sendAndConfirmTx, - buildAndSignTx, -} from "@lightprotocol/stateless.js"; -import { - LightTokenProgram, - selectMinCompressedTokenAccountsForTransfer, -} from "@lightprotocol/compressed-token"; -import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; - -const connection: Rpc = createRpc(); -const mint = new PublicKey("MINT_ADDRESS"); -const payer = PAYER_KEYPAIR; -const owner = payer; -const recipient = Keypair.generate(); -const amount = bn(1e8); - -(async () => { - const compressedTokenAccounts = - await connection.getCompressedTokenAccountsByOwner(owner.publicKey, { mint }); - - if (compressedTokenAccounts.items.length === 0) { - console.log("No compressed token accounts found"); - return; - } - - const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer( - compressedTokenAccounts.items, - amount - ); - - const proof = await connection.getValidityProof( - inputAccounts.map((account) => account.compressedAccount.hash) - ); - - const ix = await LightTokenProgram.transfer({ - payer: payer.publicKey, - inputCompressedTokenAccounts: inputAccounts, - toAddress: recipient.publicKey, - amount, - recentInputStateRootIndices: proof.rootIndices, - recentValidityProof: proof.compressedProof, - }); - - const { blockhash } = await connection.getLatestBlockhash(); - const additionalSigners = dedupeSigner(payer, [owner]); - const signedTx = buildAndSignTx( - [ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), ix], - payer, - blockhash, - additionalSigners - ); - - const transferTxId = await sendAndConfirmTx(connection, signedTx); - console.log(`Transaction: ${transferTxId}`); -})(); -``` - - - - - -### Prerequisites - -Make sure you have dependencies and developer environment set up! - - - -**Dependencies** - - - -**Developer Environment** - - - - - - -### Display Compressed Token Balances - -This example fetches and displays all compressed token balances for a wallet address. - -```javascript -import { Rpc, createRpc } from '@lightprotocol/stateless.js'; -import { Keypair, PublicKey } from '@solana/web3.js'; -import * as fs from 'fs'; -import * as os from 'os'; - -const connection: Rpc = createRpc(); - -const walletPath = `${os.homedir()}/.config/solana/id.json`; -const secretKey = JSON.parse(fs.readFileSync(walletPath, 'utf8')); -const payer = Keypair.fromSecretKey(Buffer.from(secretKey)); - -(async () => { - const balances = await connection.getCompressedTokenBalancesByOwnerV2(payer.publicKey); - - if (balances.value.items.length === 0) { - console.log("No compressed token balances found"); - return; - } - - for (const item of balances.value.items) { - const balanceValue = typeof item.balance === 'string' - ? parseInt(item.balance, 16) - : item.balance; - - const mintInfo = await connection.getAccountInfo(new PublicKey(item.mint)); - const decimals = mintInfo.data[44]; - const formattedBalance = balanceValue / Math.pow(10, decimals); - - console.log(`Mint: ${item.mint}`); - console.log(`Balance: ${formattedBalance} tokens\n`); - } -})(); -``` - - - -### Get Transaction History - -This example retrieves compression transaction signatures to display transaction history of the wallet. - -```javascript -import { Rpc, createRpc } from '@lightprotocol/stateless.js'; -import { Keypair } from '@solana/web3.js'; -import * as fs from 'fs'; -import * as os from 'os'; - -const connection: Rpc = createRpc(); - -const walletPath = `${os.homedir()}/.config/solana/id.json`; -const secretKey = JSON.parse(fs.readFileSync(walletPath, 'utf8')); -const payer = Keypair.fromSecretKey(Buffer.from(secretKey)); - -(async () => { - const signatures = await connection.getCompressionSignaturesForTokenOwner(payer.publicKey); - - if (signatures.items.length > 0) { - console.log(`Signatures:`); - signatures.items.forEach((sig, index) => { - console.log(`${index + 1}. ${sig.signature}`); - console.log(` Slot: ${sig.slot}`); - console.log(` Time: ${new Date(sig.blockTime * 1000).toISOString()}`); - }); - } else { - console.log("No transactions found"); - } -})(); -``` - - - -### Send Compressed Tokens - -First, set up a test mint to and mint 10 compressed tokens to your filesystem wallet. - - - -```typescript -import { Keypair } from "@solana/web3.js"; -import { Rpc, confirmTx, createRpc } from '@lightprotocol/stateless.js'; -import { createMint, mintTo } from '@lightprotocol/compressed-token'; -import * as fs from 'fs'; -import * as os from 'os'; - -// 1. Setup RPC connection and load filesystem wallet for mint operations -// 2. Call createMint() to create SPL mint with SPL interface for compression -// 3. Call mintTo() to mint compressed tokens to filesystem wallet - -const connection: Rpc = createRpc(); // defaults to localhost:8899 - -// Load wallet from filesystem -const walletPath = `${os.homedir()}/.config/solana/id.json`; -const secretKey = JSON.parse(fs.readFileSync(walletPath, 'utf8')); -const payer = Keypair.fromSecretKey(Buffer.from(secretKey)); -const mintKeypair = Keypair.generate(); - -(async() => { - // Fund payer with SOL - await connection.requestAirdrop(payer.publicKey, 1e9); - await new Promise(resolve => setTimeout(resolve, 1000)); - - // Create SPL mint with SPL interface for compression - const { mint, transactionSignature } = await createMint( - connection, - payer, - payer.publicKey, // mint authority - 9, - mintKeypair, - ); - console.log(`Mint address: ${mint.toString()}`); - console.log(`Transaction: ${transactionSignature}`); - - // Mint compressed tokens to payer - const mintToTxId = await mintTo( - connection, - payer, - mint, // SPL mint with SPL interface for compression - payer.publicKey, // recipient address - payer, - 10e9, - ); - - console.log(`\nMinted ${10e9 / 1e9} compressed token`); - console.log(`Transaction: ${mintToTxId}`); -})(); -``` - - - - -Make sure you add your Mint address to `send-tokens.ts`. - - -```typescript send-tokens.ts expandable -// Compressed Token Transfer - Local -// 1. Load wallet and fetch compressed token accounts with getCompressedTokenAccountsByOwner() -// 2. Select accounts for transfer using selectMinCompressedTokenAccountsForTransfer() -// and get validity proof with getValidityProof() -// 3. Create transfer instruction with LightTokenProgram.transfer() -// and submit transaction with sendAndConfirmTx() -// 4. Verify balances via getCompressedTokenAccountsByOwner() - -import { - Rpc, - createRpc, - bn, - dedupeSigner, - sendAndConfirmTx, - buildAndSignTx, -} from "@lightprotocol/stateless.js"; -import { - LightTokenProgram, - selectMinCompressedTokenAccountsForTransfer, -} from "@lightprotocol/compressed-token"; -import { ComputeBudgetProgram, Keypair, PublicKey } from "@solana/web3.js"; -import * as fs from 'fs'; -import * as os from 'os'; - -// Step 1: Setup RPC connection and define transfer parameters -const connection: Rpc = createRpc(); // defaults to localhost:8899 -const mint = new PublicKey("MINT ADDRESS"); // Replace with mint address - -// Load wallet from filesystem -const walletPath = `${os.homedir()}/.config/solana/id.json`; -const secretKey = JSON.parse(fs.readFileSync(walletPath, 'utf8')); -const payer = Keypair.fromSecretKey(Buffer.from(secretKey)); -const owner = payer; - -const recipient = Keypair.generate(); -const amount = bn(1e8); - -(async () => { - // Step 2: Fetch compressed account hashes from state trees - const compressedTokenAccounts = - await connection.getCompressedTokenAccountsByOwner(owner.publicKey, { - mint, // SPL mint with SPL interface for compression - }); - - if (compressedTokenAccounts.items.length === 0) { - console.log("No compressed token accounts found for this mint"); - return; - } - - // Show initial sender balance - const initialBalance = compressedTokenAccounts.items.reduce((sum, account) => sum + Number(account.parsed.amount), 0); - console.log(`Sender balance: ${initialBalance / 1e8} compressed tokens`); - - // Step 3: Select minimum compressed accounts for transfer amount - const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer( - compressedTokenAccounts.items, - amount - ); - - // Get validity proof for Merkle tree verification - const proof = await connection.getValidityProof( - inputAccounts.map((account) => account.compressedAccount.hash) - ); - - // Step 4: Create transfer instruction that consumes input accounts and creates new output accounts - const ix = await LightTokenProgram.transfer({ - payer: payer.publicKey, - inputCompressedTokenAccounts: inputAccounts, // accounts to consume - toAddress: recipient.publicKey, - amount, - recentInputStateRootIndices: proof.rootIndices, - recentValidityProof: proof.compressedProof, - }); - - // Step 5: Build, sign, and submit transaction - const { blockhash } = await connection.getLatestBlockhash(); - const additionalSigners = dedupeSigner(payer, [owner]); - const signedTx = buildAndSignTx( - [ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), ix], - payer, - blockhash, - additionalSigners - ); - const transferTxId = await sendAndConfirmTx(connection, signedTx); - - console.log(`\nTransferred ${amount.toNumber() / 1e8} compressed tokens`); - console.log(`Transaction: ${transferTxId}`); - console.log(`Recipient: ${recipient.publicKey.toString()}`); - - // Step 6: Verify via getCompressedTokenAccountsByOwner - const senderCompressedAccounts = await connection.getCompressedTokenAccountsByOwner(payer.publicKey, { mint }); - const senderBalance = senderCompressedAccounts.items.reduce((sum, account) => sum + Number(account.parsed.amount), 0); - - const recipientCompressedAccounts = await connection.getCompressedTokenAccountsByOwner(recipient.publicKey, { mint }); - const recipientBalance = recipientCompressedAccounts.items.reduce((sum, account) => sum + Number(account.parsed.amount), 0); - - console.log(`\nSummary compressed token balances:`); - console.log(`Sender balance: ${senderBalance / 1e8} compressed tokens`); - console.log(`Recipient balance: ${recipientBalance / 1e8} compressed token`); - - return transferTxId; -})(); -``` - - - - - -# Advanced Integrations - -Use these integrations to let users convert between regular and compressed format as needed. - - - -This example converts compressed tokens to regular SPL format using `LightTokenProgram.decompress().` - -```javascript -import { - bn, - buildAndSignTx, - sendAndConfirmTx, - dedupeSigner, - Rpc, - createRpc, -} from "@lightprotocol/stateless.js"; -import { ComputeBudgetProgram } from "@solana/web3.js"; -import { - LightTokenProgram, - getTokenPoolInfos, - selectMinCompressedTokenAccountsForTransfer, - selectTokenPoolInfosForDecompression, -} from "@lightprotocol/compressed-token"; - -// 1. Setup RPC connection and fetch compressed token accounts with getCompressedTokenAccountsByOwner() -// 2. Select accounts and SPL interface infos using selectMinCompressedTokenAccountsForTransfer() and selectTokenPoolInfosForDecompression() -// 3. Create decompress instruction with LightTokenProgram.decompress() and submit transaction - -// Step 1: Setup RPC connection and define decompression parameters -const connection: Rpc = createRpc("https://mainnet.helius-rpc.com?api-key=";); -const payer = PAYER_KEYPAIR; -const owner = PAYER_KEYPAIR; -const mint = MINT_ADDRESS; -const amount = 1e5; // 100K tokens to decompress - -(async () => { - // 1. Fetch compressed token accounts - const compressedTokenAccounts = - await connection.getCompressedTokenAccountsByOwner(owner.publicKey, { - mint, - }); - - // 2. Select - const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer( - compressedTokenAccounts.items, - bn(amount) - ); - - // 3. Fetch validity proof - const proof = await connection.getValidityProof( - inputAccounts.map((account) => account.compressedAccount.hash) - ); - - // 4. Fetch & Select tokenPoolInfos - const tokenPoolInfos = await getTokenPoolInfos(connection, mint); - const selectedTokenPoolInfos = selectTokenPoolInfosForDecompression( - tokenPoolInfos, - amount - ); - - // 5. Build instruction - const ix = await LightTokenProgram.decompress({ - payer: payer.publicKey, - inputCompressedTokenAccounts: inputAccounts, - toAddress: owner.publicKey, - amount, - tokenPoolInfos: selectedTokenPoolInfos, - recentInputStateRootIndices: proof.rootIndices, - recentValidityProof: proof.compressedProof, - }); - - - // 6. Sign, send, and confirm. - // Example with keypair: - const { blockhash } = await connection.getLatestBlockhash(); - const additionalSigners = dedupeSigner(payer, [owner]); - const signedTx = buildAndSignTx( - [ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), ix], - payer, - blockhash, - additionalSigners - ); - - return await sendAndConfirmTx(connection, signedTx); -})(); -``` - - - - - -This example converts regular SPL tokens to compressed format using `LightTokenProgram.compress().` - -```typescript -// 1. Setup RPC connection and get user ATA with getOrCreateAssociatedTokenAccount() -// 2. Fetch state tree and SPL interface infos using getStateTreeInfos() and getTokenPoolInfos() -// 3. Create compress instruction with LightTokenProgram.compress() and submit transaction - - -import { - buildAndSignTx, - sendAndConfirmTx, - Rpc, - createRpc, - selectStateTreeInfo, -} from "@lightprotocol/stateless.js"; -import { ComputeBudgetProgram } from "@solana/web3.js"; -import { - LightTokenProgram, - getTokenPoolInfos, - selectTokenPoolInfo, -} from "@lightprotocol/compressed-token"; -import { getOrCreateAssociatedTokenAccount } from "@solana/spl-token"; - -// Step 1: Setup RPC connection and define compression parameters -const connection: Rpc = createRpc( - "https://mainnet.helius-rpc.com?api-key=" -); - const payer = ; - const mint = ; -const amount = 1e5; // 100K tokens to compress - -(async () => { - // Step 2: Get or create associated token account for SPL tokens - const sourceTokenAccount = await getOrCreateAssociatedTokenAccount( - connection, - payer, // fee payer - mint, // token mint address - payer.publicKey // token account owner - ); - - // Step 3: Fetch and select state tree info for compression - const treeInfos = await connection.getStateTreeInfos(); - const treeInfo = selectStateTreeInfo(treeInfos); - - // Step 4: Fetch and select SPL interface info for compression - const tokenPoolInfos = await getTokenPoolInfos(connection, mint); - const tokenPoolInfo = selectTokenPoolInfo(tokenPoolInfos); - - // Step 5: Create compress instruction - transfer SPL tokens to pool and create compressed accounts - const compressInstruction = await LightTokenProgram.compress({ - payer: payer.publicKey, // fee payer - owner: payer.publicKey, // owner of source SPL tokens - source: sourceTokenAccount.address, // source ATA address - toAddress: payer.publicKey, // recipient of compressed tokens (self) - amount, // amount to compress - mint, // token mint address - outputStateTreeInfo: treeInfo, // state tree for compressed accounts - tokenPoolInfo, - }); - - // Step 6: Build, sign, and submit compression transaction - const { blockhash } = await connection.getLatestBlockhash(); - const tx = buildAndSignTx( - [ - ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 }), - compressInstruction, - ], - payer, // transaction signer - blockhash, - [payer] // additional signers - ); - await sendAndConfirmTx(connection, tx); -})(); -``` - - - -# Common Errors - - - -If `getCompressedTokenBalancesByOwnerV2` returns empty: - -* Ensure the wallet has compressed tokens (not regular SPL tokens) -* Verify you're on the correct network (devnet/mainnet) - - - -# Next Steps - - - diff --git a/compressed-tokens/advanced-guides/example-token-distribution.mdx b/compressed-tokens/advanced-guides/example-token-distribution.mdx deleted file mode 100644 index b034f615..00000000 --- a/compressed-tokens/advanced-guides/example-token-distribution.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: "Example Token Distribution" -description: "Reference implementations for airdrops, payments, and rewards with ZK Compression" -url: "https://github.com/Lightprotocol/example-token-distribution" -keywords: ["scalable token distribution on solana", "infrastructure for token distribution", "mass token distribution", "reward distribution for depins", "depin infrastructure on solana"] ---- - -View the full example on GitHub: [example-token-distribution](https://github.com/Lightprotocol/example-token-distribution) diff --git a/compressed-tokens/advanced-guides/how-to-combine-operations-in-one-transaction.mdx b/compressed-tokens/advanced-guides/how-to-combine-operations-in-one-transaction.mdx deleted file mode 100644 index 26fc80a6..00000000 --- a/compressed-tokens/advanced-guides/how-to-combine-operations-in-one-transaction.mdx +++ /dev/null @@ -1,198 +0,0 @@ ---- -title: Combine Instructions in One Transaction -description: Combine multiple instructions in one transaction. Full example: create SPL Interface PDA and first-time compression of existing SPL tokens. -keywords: ["batch token operations solana", "combine transactions solana"] ---- - -import InstallDependencies from '/snippets/setup/install-dependencies-codegroup.mdx'; -import SetupEnvironment from '/snippets/setup/setup-environment-tabs.mdx'; - -The SDK provides instruction-level APIs that return instructions without sending transactions. Combine these instructions to build custom transactions with multiple instructions. - -This guide demonstrates creating an SPL interface and compressing existing SPL tokens in a single transaction. - -# Full Code Example - - - -### Prerequisites - -Make sure you have dependencies and developer environment set up! - - - -**Dependencies** - - - -**Developer Environment** - - - - - - -### Create SPL interface + compress - -```typescript create-pool-and-compress.ts highlight={26,71} expandable -// 1. Setup: Create regular SPL token and mint to ATA -// 2. Build instructions for SPL interface and compress -// 3. Combine instructions in one transaction -// 4. Verify compressed balance - -import { - Keypair, - ComputeBudgetProgram, -} from '@solana/web3.js'; -import { - createRpc, - buildAndSignTx, - sendAndConfirmTx, - selectStateTreeInfo, -} from '@lightprotocol/stateless.js'; -import { LightTokenProgram } from '@lightprotocol/compressed-token'; -import { - createMint, - getOrCreateAssociatedTokenAccount, - mintTo, - TOKEN_PROGRAM_ID, -} from '@solana/spl-token'; -import BN from 'bn.js'; - -async function createPoolAndCompress() { - // Step 1: Setup - Create regular SPL token and mint to ATA - const rpc = createRpc(); - const payer = Keypair.generate(); - const airdropSignature = await rpc.requestAirdrop(payer.publicKey, 1000000000); - await rpc.confirmTransaction(airdropSignature); - - // Create regular SPL token mint - const mint = await createMint( - rpc, - payer, - payer.publicKey, - null, - 9, - undefined, - undefined, - TOKEN_PROGRAM_ID - ); - - // Create ATA and mint tokens to it - const ata = await getOrCreateAssociatedTokenAccount( - rpc, - payer, - mint, - payer.publicKey, - undefined, - undefined, - undefined, - TOKEN_PROGRAM_ID - ); - - await mintTo( - rpc, - payer, - mint, - ata.address, - payer, - 1_000_000_000, // 1 token with 9 decimals - undefined, - undefined, - TOKEN_PROGRAM_ID - ); - - console.log("Regular SPL token created:", mint.toBase58()); - console.log("ATA balance:", 1, "token"); - - // Step 2: Build instructions for SPL interface and compress - const outputStateTreeInfo = selectStateTreeInfo(await rpc.getStateTreeInfos()); - - // Derive SPL Interface PDA - const tokenPoolPda = LightTokenProgram.deriveTokenPoolPda(mint); - - // Create SPL interface instruction - const createSplInterfaceIx = await LightTokenProgram.createSplInterface({ - feePayer: payer.publicKey, - mint, - tokenProgramId: TOKEN_PROGRAM_ID, - }); - - // Manually construct TokenPoolInfo for first-time compression (SPL interface not yet on-chain) - const tokenPoolInfo = { - mint: mint, - tokenPoolPda: tokenPoolPda, - tokenProgram: TOKEN_PROGRAM_ID, - isInitialized: true, // Set to true even though pool will be created in this tx - balance: new BN(0), - poolIndex: 0, - bump: 0, // Placeholder value - }; - - // Create compress instruction - const compressIx = await LightTokenProgram.compress({ - outputStateTreeInfo, - tokenPoolInfo, - payer: payer.publicKey, - owner: payer.publicKey, - source: ata.address, - toAddress: payer.publicKey, - amount: new BN(1_000_000_000), - mint, - }); - - // Step 3: Combine instructions in one transaction - const { blockhash } = await rpc.getLatestBlockhash(); - - const allInstructions = [ - ComputeBudgetProgram.setComputeUnitLimit({ units: 1_000_000 }), - createSplInterfaceIx, - compressIx, - ]; - - const tx = buildAndSignTx( - allInstructions, - payer, - blockhash, - [] - ); - - const txId = await sendAndConfirmTx(rpc, tx); - - console.log("Token pool created and tokens compressed"); - console.log("Transaction:", txId); - - // Step 4: Verify compressed balance - const compressedAccounts = await rpc.getCompressedTokenAccountsByOwner( - payer.publicKey, - { mint } - ); - - const compressedBalance = compressedAccounts.items.reduce( - (sum, account) => sum.add(account.parsed.amount), - new BN(0) - ); - - console.log("Compressed balance:", compressedBalance.toNumber() / 1_000_000_000, "tokens"); - - return { - transactionSignature: txId, - mint, - compressedBalance: compressedBalance.toNumber(), - }; -} - -createPoolAndCompress().catch(console.error); -``` - - - -# Next Steps - - diff --git a/compressed-tokens/advanced-guides/use-token-2022-with-compression.mdx b/compressed-tokens/advanced-guides/use-token-2022-with-compression.mdx deleted file mode 100644 index 25597daa..00000000 --- a/compressed-tokens/advanced-guides/use-token-2022-with-compression.mdx +++ /dev/null @@ -1,277 +0,0 @@ ---- -title: Use Token-2022 with Compression -description: Complete guide to mint, compress and transfer tokens with Token-2022 Metadata with ZK Compression. -keywords: ["token 2022 on solana", "token extensions on solana", "token 2022 compression"] ---- - -import InstallDependencies from '/snippets/setup/install-dependencies-codegroup.mdx'; -import SetupEnvironment from '/snippets/setup/setup-environment-tabs.mdx'; - -# What you will do - -With this guide you will mint, compress, and transfer tokens with Token-2022 Metadata. - -# Overview Token 2022 Extensions - -Token 2022 Extensions are optional features that can be added to Token 2022 mints on Solana to enable additional functionality. - -ZK Compression supports compressing the following mint-extensions: - -* MetadataPointer -* TokenMetadata -* InterestBearingConfig -* GroupPointer -* GroupMemberPointer -* TokenGroup -* TokenGroupMember - -All other extensions are not yet supported. - - -If you require support for other mint-extensions, [let us know](https://t.me/swen_light)! - - -# Get started - - - - - -You need the following SDK versions: - -* `@lightprotocol/stateless.js` ≥ 0.21.0 -* `@lightprotocol/compressed-token` ≥ 0.21.0 -* `@solana/web3.js` ≥ 1.95.3 - - -Make sure you have dependencies and developer environment set up! - - - -**Dependencies** - - - -**Developer Environment** - - - - - - -Run `compress-t22.ts`. - -```typescript compress-t22.ts expandable -// Token-2022 with ZK Compression - Local -// 1. Load wallet and connect to local validator -// 2. Create Token-2022 mint with metadata extension and register for compression via createSplInterface() -// 3. Mint SPL tokens to ATA, compress via compress(), and transfer compressed tokens via transfer() -// 4. Verify balances via getTokenAccountBalance and getCompressedTokenAccountsByOwner - -import { confirmTx, createRpc } from "@lightprotocol/stateless.js"; -import { - compress, - createSplInterface, - transfer, -} from "@lightprotocol/compressed-token"; -import { - getOrCreateAssociatedTokenAccount, - mintTo as mintToSpl, - TOKEN_2022_PROGRAM_ID, - createInitializeMetadataPointerInstruction, - createInitializeMintInstruction, - ExtensionType, - getMintLen, - LENGTH_SIZE, - TYPE_SIZE, -} from "@solana/spl-token"; -import { - Keypair, - sendAndConfirmTransaction, - SystemProgram, - Transaction, -} from "@solana/web3.js"; -import { - createInitializeInstruction, - pack, - TokenMetadata, -} from "@solana/spl-token-metadata"; - -// Step 1: Setup local connection and load wallet -import * as fs from 'fs'; -import * as os from 'os'; - -const walletPath = `${os.homedir()}/.config/solana/id.json`; -const secretKey = JSON.parse(fs.readFileSync(walletPath, 'utf8')); -const payer = Keypair.fromSecretKey(Buffer.from(secretKey)); -const connection = createRpc(); // defaults to localhost:8899 - -(async () => { - - // Generate mint keypair and define Token-2022 metadata - const mint = Keypair.generate(); - const decimals = 9; - - const metadata: TokenMetadata = { - mint: mint.publicKey, - name: "Local Test Token", - symbol: "LTT", - uri: "https://example.com/token-metadata.json", - additionalMetadata: [["environment", "localnet"], ["test", "true"]], - }; - - // Calculate space requirements for Token-2022 mint with MetadataPointer extension - const mintLen = getMintLen([ExtensionType.MetadataPointer]); - const metadataLen = TYPE_SIZE + LENGTH_SIZE + pack(metadata).length; - - // Check wallet balance - const balance = await connection.getBalance(payer.publicKey); - - // Step 2: Create Token-2022 mint with metadata extension - const mintLamports = await connection.getMinimumBalanceForRentExemption( - mintLen + metadataLen - ); - - const mintTransaction = new Transaction().add( - // Create account for Token-2022 mint - SystemProgram.createAccount({ - fromPubkey: payer.publicKey, - newAccountPubkey: mint.publicKey, - space: mintLen, - lamports: mintLamports, - programId: TOKEN_2022_PROGRAM_ID, - }), - // Initialize MetadataPointer extension - createInitializeMetadataPointerInstruction( - mint.publicKey, - payer.publicKey, - mint.publicKey, - TOKEN_2022_PROGRAM_ID - ), - // Initialize Token-2022 mint account - createInitializeMintInstruction( - mint.publicKey, - decimals, - payer.publicKey, - null, - TOKEN_2022_PROGRAM_ID - ), - // Initialize token metadata - createInitializeInstruction({ - programId: TOKEN_2022_PROGRAM_ID, - mint: mint.publicKey, - metadata: mint.publicKey, - name: metadata.name, - symbol: metadata.symbol, - uri: metadata.uri, - mintAuthority: payer.publicKey, - updateAuthority: payer.publicKey, - }) - ); - - // Send Token-2022 mint creation transaction - const mintCreationTxId = await sendAndConfirmTransaction( - connection, - mintTransaction, - [payer, mint] - ); - console.log(`Token-2022 mint created with address: ${mint.publicKey.toString()}`); - - // Step 3: Call createSplInterface() to initialize omnibus account - // and register Token-2022 mint with Light Token Program - // Create PDA that holds SPL tokens for compressed tokens - const registerTxId = await createSplInterface( - connection, - payer, - mint.publicKey, // Token-2022 mint to register with Light Token Program - undefined, - TOKEN_2022_PROGRAM_ID - ); - - // Step 4: Create associated token account and mint tokens - const ata = await getOrCreateAssociatedTokenAccount( - connection, - payer, - mint.publicKey, // Token-2022 mint with SPL interface for compression - payer.publicKey, - undefined, - undefined, - undefined, - TOKEN_2022_PROGRAM_ID - ); - - // Mint Token-2022 tokens to ATA - const mintAmount = 400_000_000; // 0.4 tokens - const mintToTxId = await mintToSpl( - connection, - payer, - mint.publicKey, // Token-2022 mint with SPL interface for compression - ata.address, // destination token account - payer.publicKey, // mint authority - mintAmount, // amount to mint - undefined, // multiSigners (not used for single authority) - undefined, - TOKEN_2022_PROGRAM_ID - ); - console.log(`Minted ${mintAmount / 1e9} Token-2022 tokens with metadata extension`); - console.log(`Transaction: ${mintToTxId}`); - - // Step 5: Call compress() to convert Token-2022 tokens to compressed format - // Transfer Token-2022 tokens to omnibus pool and mint compressed tokens - const compressAmount = 300_000_000; // 0.3 tokens - const compressTxId = await compress( - connection, - payer, - mint.publicKey, // Token-2022 mint with SPL interface for compression - compressAmount, // amount to compress - payer, // owner of SPL tokens - ata.address, // Source ATA for compression - payer.publicKey // recipient for compressed tokens - ); - console.log(`\nCompressed ${compressAmount / 1e9} Token-2022 tokens`); - console.log(`Transaction: ${compressTxId}`); - - // Step 6: Transfer compressed Token-2022 tokens - const transferRecipient = Keypair.generate(); // Keypair recipient - const transferAmount = 100_000_000; // 0.1 tokens - const transferTxId = await transfer( - connection, - payer, - mint.publicKey, // Token-2022 mint with SPL interface for compression - transferAmount, - payer, - transferRecipient.publicKey - ); - console.log(`\nTransferred ${transferAmount / 1e9} Compressed Token-2022 tokens`); - console.log(`Transaction: ${transferTxId}`); - console.log(`Recipient: ${transferRecipient.publicKey.toString()}`); - - // Step 7: Verify balances via getTokenAccountBalance and getCompressedTokenAccountsByOwner - const senderCompressedAccounts = await connection.getCompressedTokenAccountsByOwner(payer.publicKey, { mint: mint.publicKey }); - const senderBalance = senderCompressedAccounts.items.reduce((sum, account) => sum + Number(account.parsed.amount), 0); - - const recipientCompressedAccounts = await connection.getCompressedTokenAccountsByOwner(transferRecipient.publicKey, { mint: mint.publicKey }); - const recipientBalance = recipientCompressedAccounts.items.reduce((sum, account) => sum + Number(account.parsed.amount), 0); - - const splBalance = await connection.getTokenAccountBalance(ata.address); - - console.log(`\nSummary Token-2022 balances:`); - console.log(`Sender balance: ${senderBalance / 1e9} compressed tokens / ${splBalance.value.uiAmount} SPL tokens`); - console.log(`Recipient balance: ${recipientBalance / 1e9} compressed tokens`); - -})().catch(console.error); -``` - - - -# Next Steps - - - - diff --git a/compressed-tokens/advanced-guides/airdrop.mdx b/compressed-tokens/airdrop.mdx similarity index 100% rename from compressed-tokens/advanced-guides/airdrop.mdx rename to compressed-tokens/airdrop.mdx diff --git a/compressed-tokens/guides.mdx b/compressed-tokens/guides.mdx deleted file mode 100644 index 16a44ebd..00000000 --- a/compressed-tokens/guides.mdx +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: Guides -description: "Overview of guides to compressed token operations and reference table with descriptions. Guides include full code examples, troubleshooting, and advanced configurations." -sidebarTitle: "Overview" ---- - -import GuidesTable from '/snippets/overview-tables/compressed-tokens-guides-table.mdx'; - - diff --git a/compressed-tokens/guides/add-token-pools-to-mint-accounts.mdx b/compressed-tokens/guides/add-token-pools-to-mint-accounts.mdx deleted file mode 100644 index bcc62989..00000000 --- a/compressed-tokens/guides/add-token-pools-to-mint-accounts.mdx +++ /dev/null @@ -1,111 +0,0 @@ ---- -title: Create SPL Interface for Existing Mints -description: "Create an SPL Interface PDA (omnibus account) for an existing SPL mint. Requires only fee_payer with no mint authority constraint." -keywords: ["SPL interface", "compression", "omnibus account"] ---- - -import FullSetup from "/snippets/setup/full-setup.mdx"; -import ActionCode from '/snippets/code-snippets/compressed-token/create-token-pool/action.mdx'; - -Create an SPL interface (omnibus account) for an existing SPL mint. `createSplInterface()` requires only `fee_payer` and has no mint authority constraint. - - -The SPL Interface PDA requires rent; individual compressed token accounts are rent-free. - - - -```typescript function-create-token-pool.ts -// Creates SPL interface (omnibus account) for existing SPL mint -const transactionSignature = await createSplInterface( - rpc, - payer, - mint, -); -``` - - - -**Best Practice:** Each mint supports up to 4 SPL interfaces. During compression/decompression, SPL Interface PDAs get write-locked. Use `addTokenPools()` to create additional interfaces and increase per-block write-lock capacity. - - -## Get Started - - - -### Create SPL interface - - - - - - - -# Troubleshooting - - - - -The mint has no SPL Interface PDA. - -```typescript -const poolTx = await createSplInterface(rpc, payer, mint); -console.log("SPL interface created:", poolTx); -``` - - - - -# Advanced Configuration - - - - -Create SPL interfaces for multiple mints: - -```typescript -const mints = [ - new PublicKey("MINT_1_ADDRESS"), - new PublicKey("MINT_2_ADDRESS"), - new PublicKey("MINT_3_ADDRESS"), -]; - -for (const mint of mints) { - try { - const poolTx = await createSplInterface(rpc, payer, mint); - console.log(`SPL interface created for ${mint.toBase58()}:`, poolTx); - } catch (error) { - console.log(`Failed for ${mint.toBase58()}:`, error.message); - } -} -``` - - - - - -Create SPL interface for Token-2022 mints: - -```typescript -import { TOKEN_2022_PROGRAM_ID } from '@solana/spl-token'; - -const poolTx = await createSplInterface( - rpc, - payer, - mint, // Token-2022 mint - undefined, - TOKEN_2022_PROGRAM_ID, -); -``` - - - - -# Next Steps - - diff --git a/compressed-tokens/guides/compress-decompress.mdx b/compressed-tokens/guides/compress-decompress.mdx deleted file mode 100644 index af196600..00000000 --- a/compressed-tokens/guides/compress-decompress.mdx +++ /dev/null @@ -1,217 +0,0 @@ ---- -title: Compress and Decompress SPL Tokens -description: "Convert SPL tokens between compressed and regular format with compress() and decompress()." -keywords: ["compress spl tokens", "decompress tokens on solana"] ---- - -import FullSetup from "/snippets/setup/full-setup.mdx"; -import MintPrereq from '/snippets/setup/compressed-tokens-mint-prereq.mdx'; -import CompressActionCode from '/snippets/code-snippets/compressed-token/compress/action.mdx'; -import DecompressActionCode from '/snippets/code-snippets/compressed-token/decompress/action.mdx'; - - -```typescript compress() -// Compress SPL tokens to compressed tokens -const compressionSignature = await compress( - rpc, - payer, - mint, // SPL mint with SPL interface for compression - amount, - payer, // owner of SPL tokens - tokenAccount.address, // source SPL token account (sourceTokenAccount parameter) - recipient, // recipient owner address (toAddress parameter) -); -``` - -```typescript decompress() -// Decompress compressed tokens to SPL tokens -const transactionSignature = await decompress( - rpc, - payer, - mint, // SPL mint with SPL interface for compression - amount, - payer, // owner of compressed tokens - tokenAccount.address, // destination token account (toAddress parameter) -); -``` - - - -**Function Difference and Best Practice:** - -* `compress(amount, sourceTokenAccount, toAddress)` compresses specific amounts from source to a specified recipient. Use for transfers and precise amounts. -* `compressSplTokenAccount(tokenAccount, remainingAmount)` compresses the entire SPL token account balance minus optional remaining amount only to the same owner. Use to migrate complete token accounts with optional partial retention. [Here is how](/compressed-tokens/guides/compress-spl-token-account). - - -## Get Started - - - -### Compress / Decompress Tokens - - - - -Before we can compress or decompresss, we need: - -* An SPL mint with an SPL interface. Create one for new mints via [`createMint()`](/compressed-tokens/guides/create-mint-with-token-pool) or for existing mints via [`createSplInterface()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts). -* For `compress()` SPL tokens in an Associated Token Account, or -* For `decompress()` compressed token accounts with sufficient balance. - - - - - - - - - - - - - - -# Troubleshooting - - - - -Check your balances before operations: - -```typescript -// For decompression - check compressed balance -const compressedAccounts = await rpc.getCompressedTokenAccountsByOwner( - owner.publicKey, - { mint } -); -const compressedBalance = compressedAccounts.items.reduce( - (sum, account) => sum.add(account.parsed.amount), - new BN(0) -); - -// For compression - check SPL token balance -const tokenBalance = await rpc.getTokenAccountBalance(tokenAccount); -const splBalance = new BN(tokenBalance.value.amount); - -console.log("Can decompress up to:", compressedBalance.toString()); -console.log("Can compress up to:", splBalance.toString()); -``` - - - - - -Ensure the signer owns the tokens being decompressed/compressed: - -```typescript -// The owner parameter must be the actual owner -const decompressTx = await decompress( - rpc, - payer, // can be different (pays fees) - mint, - amount, - actualOwner, // must own compressed tokens - destinationAta, -); - -const compressTx = await compress( - rpc, - payer, // can be different (pays fees) - mint, - amount, - actualOwner, // must own SPL tokens - sourceAta, - recipient, -); -``` - - - - -# Advanced Configuration - - - - -Compress tokens directly to someone else: - -```typescript -const recipientWallet = new PublicKey("RECIPIENT_WALLET_ADDRESS"); - -// Compress your SPL tokens to recipient -const compressTx = await compress( - rpc, - payer, - mint, - amount, - tokenOwner, // current owner signs - tokenAccount, // your token account - recipientWallet, // recipient gets compressed tokens -); -``` - - - - - -Compress multiple token accounts: - -```typescript -// Compress to multiple recipients at once -const recipients = [recipient1.publicKey, recipient2.publicKey, recipient3.publicKey]; -const amounts = [1_000_000_000, 2_000_000_000, 500_000_000]; // Different amounts - -const batchCompressTx = await compress( - rpc, - payer, - mint, - amounts, // Array of amounts - owner, - tokenAccount, - recipients, // Array of recipients -); - -console.log("Batch compression completed:", batchCompressTx); -``` - - - - - -Decompress tokens using delegate authority: - -```typescript -import { decompressDelegated } from '@lightprotocol/compressed-token'; -import { getAssociatedTokenAddress, TOKEN_PROGRAM_ID } from '@solana/spl-token'; - -// Get ATA for decompressed tokens -const ataAddress = await getAssociatedTokenAddress( - mint, - recipient, - false, - TOKEN_PROGRAM_ID -); - -// Delegate decompresses tokens -await decompressDelegated( - rpc, - payer, - mint, - amount, - delegate, // Signer - owner of compressed tokens - ataAddress, // Uncompressed token account (ATA) -); -``` - - - - -# Next Steps - - diff --git a/compressed-tokens/guides/compress-spl-token-account.mdx b/compressed-tokens/guides/compress-spl-token-account.mdx deleted file mode 100644 index 3c0d1d6e..00000000 --- a/compressed-tokens/guides/compress-spl-token-account.mdx +++ /dev/null @@ -1,189 +0,0 @@ ---- -title: Compress Complete SPL Token Accounts -description: "Compress the entire balance of an SPL token account to reclaim rent. Optionally leave some tokens in SPL format." -keywords: ["compress spl token accounts", "migrate spl to compressed"] ---- - -import FullSetup from "/snippets/setup/full-setup.mdx"; -import MintPrereq from '/snippets/setup/compressed-tokens-mint-prereq.mdx'; -import ActionCode from '/snippets/code-snippets/compressed-token/compress-spl-account/action.mdx'; - - -```typescript compressSplTokenAccount() -// Compress entire SPL token account balance -const transactionSignature = await compressSplTokenAccount( - rpc, - payer, - mint, // SPL mint with SPL interface for compression - owner, - tokenAccount, // SPL token account to compress -); -``` - -```typescript partialCompression() -// Compress account while keeping some tokens in SPL format -const transactionSignature = await compressSplTokenAccount( - rpc, - payer, - mint, // SPL mint with SPL interface for compression - owner, - tokenAccount, // SPL token account to compress - remainingAmount, // amount to keep in SPL format -); -``` - - - -After compression, empty token accounts can now be closed to reclaim rent with [`closeAccount()`](https://solana.com/developers/cookbook/tokens/close-token-accounts). - - - -**Function Difference and Best Practice:** - -* `compressSplTokenAccount(tokenAccount, remainingAmount)` compresses the entire SPL token account balance minus optional remaining amount only to the same owner. Use to migrate complete token accounts with optional partial retention. -* `compress(amount, sourceTokenAccount, toAddress)` compresses specific amounts from source to a specified recipient. Use for transfers and precise amounts. [Here is how](/compressed-tokens/guides/compress-decompress). - - -## Get Started - - - -### Compress SPL Token Accounts - - - - - - - - - - -# Troubleshooting - - - - -The token account doesn't have enough tokens for the operation. - -```typescript -// Check token account balance before compression -const balance = await rpc.getTokenAccountBalance(tokenAccount); - -if (Number(balance.value.amount) === 0) { - console.log("Token account is empty"); - return; -} - -console.log("Available balance:", Number(balance.value.amount)); - -// Proceed with compression -const compressTx = await compressSplTokenAccount( - rpc, - payer, - mint, - owner, - tokenAccount, -); -``` - - - - - -The `remainingAmount` parameter exceeds the current account balance. - -```typescript -const balance = await rpc.getTokenAccountBalance(tokenAccount); -const availableAmount = Number(balance.value.amount); -const remainingAmount = bn(500_000_000); // 0.5 tokens - -if (remainingAmount.gt(bn(availableAmount))) { - console.log(`Cannot leave ${remainingAmount.toString()} tokens`); - console.log(`Available balance: ${availableAmount}`); - throw new Error("Remaining amount exceeds balance"); -} - -// Use valid remaining amount -const compressTx = await compressSplTokenAccount( - rpc, - payer, - mint, - owner, - tokenAccount, - remainingAmount, // must be <= balance -); -``` - - - - -# Advanced Configuration - - - - -Compress most tokens while leaving some in SPL format: - -```typescript -import { bn } from '@lightprotocol/stateless.js'; - -// Leave 100 tokens (0.1 with 9 decimals) in SPL account -const remainingAmount = bn(100_000_000); - -const compressTx = await compressSplTokenAccount( - rpc, - payer, - mint, - owner, - tokenAccount, - remainingAmount, // amount to keep in SPL format -); - -// Account will retain remainingAmount tokens -``` - - - - - -Compress several token accounts for the same mint: - -```typescript -const tokenAccounts = [ - { account: new PublicKey("ACCOUNT_1"), owner: owner1 }, - { account: new PublicKey("ACCOUNT_2"), owner: owner2 }, - { account: new PublicKey("ACCOUNT_3"), owner: owner3 }, -]; - -// Compress each account -for (const { account, owner } of tokenAccounts) { - console.log(`Compressing account: ${account.toBase58()}`); - - try { - const compressTx = await compressSplTokenAccount( - rpc, - payer, - mint, - owner, - account, - ); - console.log(`Compressed: ${compressTx}`); - } catch (error) { - console.log(`Failed: ${error.message}`); - } -} -``` - - - - -# Next Steps - - diff --git a/compressed-tokens/guides/create-compressed-token-accounts.mdx b/compressed-tokens/guides/create-compressed-token-accounts.mdx deleted file mode 100644 index 28eecd3f..00000000 --- a/compressed-tokens/guides/create-compressed-token-accounts.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: Create Compressed Token Accounts -description: Short guide to compressed token account creation with ZK Compression on Solana and difference to regular token accounts. -keywords: ["create compressed token account", "rent free token accounts on solana"] ---- - -Compressed token accounts store ownership information for compressed tokens like regular token accounts with two core differences. Compressed Tokens - -* do not require an Associated Token Accounts (ATAs), and -* do not require a rent-exempt balance. - -Compressed token accounts are created in the following scenarios: - -1. `mintTo()` creates compressed token accounts for recipients. - -How to Mint Compressed Tokens - -2. `transfer()` consumes existing accounts of the sender as input, and creates new compressed token accounts with updated balances as output for the sender and recipient(s). - -Transfer Compressed Tokens \ No newline at end of file diff --git a/compressed-tokens/guides/create-mint-with-token-pool.mdx b/compressed-tokens/guides/create-mint-with-token-pool.mdx deleted file mode 100644 index e9decac6..00000000 --- a/compressed-tokens/guides/create-mint-with-token-pool.mdx +++ /dev/null @@ -1,99 +0,0 @@ ---- -title: Create a Mint with SPL Interface for Compression -description: "Create an SPL token mint with an SPL Interface PDA (omnibus account) for compression. The SPL interface holds SPL tokens while compressed and releases them when decompressed." -keywords: ["register mint for compression", "compressed mint account", "SPL interface"] ---- - -import FullSetup from "/snippets/setup/full-setup.mdx"; -import ActionCode from '/snippets/code-snippets/compressed-token/create-mint/action.mdx'; -import InstructionCode from '/snippets/code-snippets/compressed-token/create-mint/instruction.mdx'; - -The mint account itself requires rent (like regular SPL mints), but individual compressed token accounts are rent-free. -Create an SPL interface (omnibus account) for an existing SPL mint with [`createSplInterface()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts) or use `createMint()` to create a new one from scratch. - - -```typescript createMint() -// Create SPL mint with SPL interface for compression -const { mint, transactionSignature } = await createMint( - rpc, - payer, - mintAuthority.publicKey, - decimals, -); -``` - - - -**Best Practice:** Each mint supports up to 4 SPL interfaces. During compression/decompression, SPL Interface PDAs get write-locked. Use `addTokenPools()` to create additional interfaces and increase per-block write-lock capacity. - - -## Get Started - - - -### Create a mint with SPL interface for compression - - - - - - - - - - - - - - -# Advanced Configuration - - - - -Customize who can mint new compressed tokens. - -```typescript -const mintAuthority = Keypair.generate(); - -const { mint, transactionSignature } = await createMint( - rpc, - payer, - mintAuthority.publicKey, - 9, -); -``` - - - - - -Customize who can freeze/thaw compressed token accounts. - -```typescript -const freezeAuthority = Keypair.generate(); - -const { mint, transactionSignature } = await createMint( - rpc, - payer, - payer.publicKey, // mint authority - 9, // decimals - Keypair.generate(), // mint keypair - undefined, // confirm options - undefined, // token program ID - freezeAuthority.publicKey, // freeze authority -); -``` - - - - -# Next Steps - - diff --git a/compressed-tokens/guides/delegate.mdx b/compressed-tokens/guides/delegate.mdx deleted file mode 100644 index a17c7c84..00000000 --- a/compressed-tokens/guides/delegate.mdx +++ /dev/null @@ -1,166 +0,0 @@ ---- -title: Approve and Revoke Delegate Authority -description: "Grant and remove delegate spending authority for compressed tokens with approve() and revoke(). Only the token owner can perform these operations." -keywords: ["delegate authority on solana", "token delegation compressed"] ---- - -import FullSetup from "/snippets/setup/full-setup.mdx"; -import ApproveActionCode from '/snippets/code-snippets/compressed-token/approve/action.mdx'; -import RevokeActionCode from '/snippets/code-snippets/compressed-token/revoke/action.mdx'; - -The `approve()` and `revoke()` functions grant and remove delegate spending authority for compressed tokens. Only the token owner can perform these instructions. - - -```typescript approve() -// Approve delegate for spending up to the specified amount -const approveSignature = await approve( - rpc, - payer, - mint, // SPL mint with SPL interface for compression - amount, - owner, - delegate.publicKey, // delegate account -); -``` - -```typescript revoke() -// Get delegated accounts for revocation -const delegatedAccounts = await rpc.getCompressedTokenAccountsByDelegate( - delegate.publicKey, - { mint } -); - -// Revoke delegate authority -const revokeSignature = await revoke( - rpc, - payer, - delegatedAccounts.items, // delegated compressed token accounts - owner, -); -``` - - -## Get Started - - - -### Approve / Revoke Delegates - - - - - - - - - - - - - -Before we approve or revoke delegates, we need: - -* compressed token accounts to delegate or revoke delegation from, and -* an SPL mint with an SPL interface. Create one for new mints via [`createMint()`](/compressed-tokens/guides/create-mint-with-token-pool) or for existing mints via [`createSplInterface()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts). - - - - - -# Troubleshooting - - - - -Attempting to revoke non-delegated accounts. - -```typescript -/// Verify accounts are delegated before revocation. -const delegateAccounts = await rpc.getCompressedTokenAccountsByDelegate( - delegate.publicKey, - { mint } -); - -if (delegateAccounts.items.length === 0) { - console.log("No delegated accounts to revoke"); - return; -} -``` - - - - -# Advanced Configuration - - - - -```typescript -const delegates = [ - Keypair.generate().publicKey, - Keypair.generate().publicKey, -]; - -const amounts = [ - 200_000_000, // 0.2 tokens to first delegate - 300_000_000, // 0.3 tokens to second delegate -]; - -// Approve each delegate -for (let i = 0; i < delegates.length; i++) { - const approveTx = await approve( - rpc, - payer, - mint, - amounts[i], - tokenOwner, - delegates[i], - ); - - console.log(`Delegate ${i + 1} approved:`, approveTx); -} -``` - - - - - -```typescript -const delegates = [ - new PublicKey("DELEGATE_1_ADDRESS"), - new PublicKey("DELEGATE_2_ADDRESS"), -]; - -// Revoke each delegate -for (const delegate of delegates) { - // Get delegated accounts for this delegate - const delegateAccounts = await rpc.getCompressedTokenAccountsByDelegate( - delegate, - { mint } - ); - - if (delegateAccounts.items.length > 0) { - const revokeTx = await revoke( - rpc, - payer, - delegateAccounts.items, - tokenOwner, - ); - - console.log(`Delegate ${delegate.toBase58()} revoked:`, revokeTx); - } -} -``` - - - - -# Next Steps - - diff --git a/compressed-tokens/guides/merge-compressed-token-accounts.mdx b/compressed-tokens/guides/merge-compressed-token-accounts.mdx deleted file mode 100644 index 278547b2..00000000 --- a/compressed-tokens/guides/merge-compressed-token-accounts.mdx +++ /dev/null @@ -1,145 +0,0 @@ ---- -title: Merge Compressed Token Accounts -description: "Consolidate multiple compressed token accounts of the same mint into a single account to reduce fragmentation." -keywords: ["merge compressed token accounts", "consolidate token accounts"] ---- - -import FullSetup from "/snippets/setup/full-setup.mdx"; -import ActionCode from '/snippets/code-snippets/compressed-token/merge-token-accounts/action.mdx'; - -The `mergeTokenAccounts()` function consolidates multiple compressed accounts of the same mint into a single compressed account. - -The function - -1. consumes multiple compressed token accounts (up to 8 accounts), and -2. creates a single output compressed token account with combined balance for the owner. - - -State trees where compressed account's are stored, are append only. `mergeTokenAccounts()` reduces account fragmentation to simplify balance calculations from `getCompressedTokenAccountsByOwner`. - - - -```typescript function-merge-accounts.ts -// Combines multiple compressed token accounts into single compressed account -const transactionSignature = await mergeTokenAccounts( - rpc, - payer, - mint, // SPL mint with SPL interface for compression - owner, -); -``` - - -## Get Started - - - -### Merge Compressed Accounts - - - - - - -Before we merge compressed accounts, we need - -* Multiple compressed token accounts of the same mint owned by the same wallet, and -* an SPL mint with an SPL interface. Create one for new mints via [`createMint()`](/compressed-tokens/guides/create-mint-with-token-pool) or for existing mints via [`createSplInterface()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts). - - - - - -# Troubleshooting - - - - -The owner has no compressed token accounts for the specified mint: - -```typescript -// Check if accounts exist before merging -const accounts = await rpc.getCompressedTokenAccountsByOwner( - owner.publicKey, - { mint } -); - -if (accounts.items.length === 0) { - console.log("No compressed token accounts found for this mint"); - console.log("Mint address:", mint.toBase58()); - console.log("Owner address:", owner.publicKey.toBase58()); - return; -} - -console.log(`Found ${accounts.items.length} accounts to merge`); -``` - - - - -# Advanced Configuration - - - - -```typescript -// Get account count -const accounts = await rpc.getCompressedTokenAccountsByOwner( - owner.publicKey, - { mint } -); - -// Only merge if more than 2 accounts -if (accounts.items.length > 2) { - console.log(`Merging ${accounts.items.length} accounts...`); - - const mergeTx = await mergeTokenAccounts( - rpc, - payer, - mint, - tokenOwner, - ); - - console.log("Merge completed:", mergeTx); -} else { - console.log("Merge not needed - optimal account structure"); -} -``` - - - - - -```typescript -const mints = [ - new PublicKey("MINT_1_ADDRESS"), - new PublicKey("MINT_2_ADDRESS"), -]; - -// Merge accounts for each mint -for (const mint of mints) { - console.log(`Merging accounts for mint: ${mint.toBase58()}`); - - const mergeTx = await mergeTokenAccounts( - rpc, - payer, - mint, - tokenOwner, - ); - - console.log(`Merge completed: ${mergeTx}`); -} -``` - - - - -# Next Steps - - diff --git a/compressed-tokens/guides/mint-compressed-tokens.mdx b/compressed-tokens/guides/mint-compressed-tokens.mdx deleted file mode 100644 index fe5b0fa4..00000000 --- a/compressed-tokens/guides/mint-compressed-tokens.mdx +++ /dev/null @@ -1,154 +0,0 @@ ---- -title: Mint Compressed Tokens -description: "Mint tokens to compressed token accounts for recipients and increases a mint's token supply. Only the mint authority can perform this operation." -keywords: ["mint compressed tokens on solana", "scalable token minting"] ---- - -import FullSetup from "/snippets/setup/full-setup.mdx"; -import MintPrereq from '/snippets/setup/compressed-tokens-mint-prereq.mdx'; -import ActionCode from '/snippets/code-snippets/compressed-token/mint-to/action.mdx'; -import InstructionCode from '/snippets/code-snippets/compressed-token/mint-to/instruction.mdx'; - -```typescript -// Mint compressed tokens - mints SPL tokens to pool, creates compressed token accounts -const transactionSignature = await mintTo( - rpc, - payer, - mint, // SPL mint with SPL interface for compression - recipient, // recipient address (toPubkey parameter) - payer, // mint authority - amount, -); -``` - -## Get Started - - - -### Mint Compressed Tokens - - - - - - - - - - - - - - - - -# Troubleshooting - - - - - -```typescript -// Error: SPL interface not found for this mint. Create a compressed token -// SPL interface PDA for mint: [ADDRESS] via createSplInterface(). -``` - -The mint has no SPL Interface PDA. Ensure you created the mint using `createMint` or call `createSplInterface()` for an existing mint. - -```typescript -// Create mint with SPL interface for compression -import { createMint } from '@lightprotocol/compressed-token'; -const { mint } = await createMint(rpc, payer, payer.publicKey, 9); -``` - - - - - -The SPL interface info doesn't correspond to the mint address. Ensure you're fetching the correct interface: - -```typescript -// Get SPL interface infos for your mint -const tokenPoolInfo = await getTokenPoolInfos(rpc, mint); -``` - - - - - -When minting to multiple recipients, ensure arrays are the same size. - -```typescript -// Wrong: Mismatched array lengths -const recipients = [addr1, addr2, addr3]; -const amounts = [100, 200]; // Only 2 amounts for 3 recipients - -// Correct: Same length arrays -const recipients = [addr1, addr2, addr3]; -const amounts = [100, 200, 300]; // 3 amounts for 3 recipients -``` - - - - -# Advanced Configuration - - - - -```typescript -// Mint different amounts to multiple recipients -const recipients = [ - Keypair.generate().publicKey, - Keypair.generate().publicKey, - Keypair.generate().publicKey, -]; - -const amounts = [ - 1_000_000_000, // 1 token - 2_000_000_000, // 2 tokens - 500_000_000, // 0.5 tokens -]; - -const transactionSignature = await mintTo( - rpc, - payer, - mint, // SPL mint with SPL interface for compression - recipients, // array of recipients (toPubkey parameter) - payer, // mint authority - amounts, // array of amounts (amount parameter) -); -``` - - - - - -Mint tokens using a custom mint authority with `approveAndMintTo()`: - -```typescript -import { approveAndMintTo } from '@lightprotocol/compressed-token'; - -// Mint tokens with a separate mint authority -const transactionSignature = await approveAndMintTo( - rpc, - payer, - mint, // SPL mint with SPL interface for compression - recipient.publicKey, // recipient of minted tokens (toPubkey parameter) - mintAuthority, // mint authority - mintAmount, -); -``` - - - - -# Next Steps - - \ No newline at end of file diff --git a/compressed-tokens/guides/transfer-compressed-tokens.mdx b/compressed-tokens/guides/transfer-compressed-tokens.mdx deleted file mode 100644 index 3e10eb27..00000000 --- a/compressed-tokens/guides/transfer-compressed-tokens.mdx +++ /dev/null @@ -1,190 +0,0 @@ ---- -title: Transfer Compressed Tokens -description: "Transfer compressed tokens between accounts. Transfers consume input accounts and create new output accounts with updated balances." -keywords: ["transfer compressed tokens", "token transfer on solana"] ---- - -import FullSetup from "/snippets/setup/full-setup.mdx"; -import MintPrereq from '/snippets/setup/compressed-tokens-mint-prereq.mdx'; -import ActionCode from '/snippets/code-snippets/compressed-token/transfer/action.mdx'; - -The `transfer()` function moves compressed tokens between accounts. -* SPL token transfers that update the existing account -* Compressed token transfers consume input accounts from the sender and create new output accounts for sender and recipient with updated balances. - -SPL token accounts can be compressed in the same transaction with `compress_or_decompress_amount`, if needed. - - - -```typescript function-transfer-compressed-tokens.ts -// Transfer compressed tokens -const transactionSignature = await transfer( - rpc, - payer, - mint, // SPL mint with SPL interface for compression - amount, - payer, - recipient, // destination address (toAddress parameter) -) -``` - -## Get Started - - - -### Transfer Compressed Tokens - - - - - - - - - -# Troubleshooting - - - - -The sender doesn't have enough compressed tokens for the requested transfer amount. - -```typescript -// Check current balance first -const tokenAccounts = await rpc.getCompressedTokenAccountsByOwner( - owner.publicKey, - { mint } -); - -if (tokenAccounts.items.length === 0) { - throw new Error("No compressed token accounts found"); -} - -// Calculate total balance across all accounts -const totalBalance = tokenAccounts.items.reduce( - (sum, account) => sum.add(account.parsed.amount), - new BN(0) -); - -console.log("Available balance:", totalBalance.toString()); - -// Ensure transfer amount doesn't exceed balance -if (new BN(transferAmount).gt(totalBalance)) { - throw new Error(`Transfer amount ${transferAmount} exceeds balance ${totalBalance.toString()}`); -} -``` - - - - - -The transfer requires more than 4 compressed accounts, which exceeds the transaction limit. - -```typescript -// Error message: "Account limit exceeded: max X (4 accounts) per transaction. -// Total balance: Y (Z accounts). Consider multiple transfers to spend full balance." - -// Split into multiple smaller transfers -const maxTransferPerTx = 1_000_000_000; // Adjust based on your account sizes - -if (transferAmount > maxTransferPerTx) { - console.log("Large transfer detected, splitting into multiple transactions..."); - - let remainingAmount = transferAmount; - while (remainingAmount > 0) { - const currentTransfer = Math.min(remainingAmount, maxTransferPerTx); - - await transfer( - rpc, - payer, - mint, - currentTransfer, - owner, - recipient - ); - - remainingAmount -= currentTransfer; - console.log(`Transferred ${currentTransfer}, remaining: ${remainingAmount}`); - } -} -``` - - - - -# Advanced Configuration - - - - -Transfer to multiple recipients in separate transactions: - -```typescript -const recipients = [ - Keypair.generate().publicKey, - Keypair.generate().publicKey, - Keypair.generate().publicKey, -]; - -const amounts = [ - 100_000_000, // 0.1 tokens - 200_000_000, // 0.2 tokens - 150_000_000, // 0.15 tokens -]; - -for (let i = 0; i < recipients.length; i++) { - const transactionSignature = await transfer( - rpc, - payer, - mint, - amounts[i], - owner, - recipients[i], - ); - - console.log(`Transfer ${i + 1} completed:`, transactionSignature); -} -``` - - - - - -Transfer tokens using delegate authority: - -```typescript -import { approve, transferDelegated } from '@lightprotocol/compressed-token'; - -// 1. Owner approves delegate -await approve( - rpc, - payer, - mint, - amount, - owner, // Signer - delegate.publicKey, // PublicKey -); - -// 2. Delegate transfers tokens -await transferDelegated( - rpc, - payer, - mint, - transferAmount, - delegate, // Signer - named "owner" in SDK - recipient, -); -``` - - - - -# Next Steps - - diff --git a/compressed-tokens/overview.mdx b/compressed-tokens/overview.mdx index 0dceae4c..9f97ba98 100644 --- a/compressed-tokens/overview.mdx +++ b/compressed-tokens/overview.mdx @@ -1,6 +1,6 @@ --- title: Overview -description: "Overview to compressed tokens and guides with full code examples. Use for distributing tokens (eg rewards, airdrops) or creating associated token accounts for users." +description: "Compressed tokens are the most efficient way to distribute SPL tokens (eg rewards, airdrops). For other token purposes use Light Token." keywords: ["compressed tokens on solana", "scalable token distribution on solana", "infrastructure for token distribution", "airdrop infrastructure on solana", "launchpad infrastructure on solana"] --- @@ -14,7 +14,7 @@ import { TokenAccountCompressedVsSpl } from "/snippets/jsx/token-account-compres **Note: The new [Light Token Program Beta](/light-token/welcome)** is live on Solana Devnet with mainnet expected in Q1 2026. We recommend to use Light Token for most purposes except airdrops and other forms of token distribution. The SDK for compressed tokens can still be used once Light Token is on Solana Mainnet. -For production use today, use Compressed Tokens, which are on Solana Mainnet. +For production use today, use Compressed Tokens, which are on Solana Mainnet. | Creation | Solana | Compressed | @@ -35,10 +35,10 @@ For production use today, use Compressed Tokens, which are on Solana Mainnet. Distribute tokens without paying upfront rent per recipient. @@ -50,44 +50,31 @@ For production use today, use Compressed Tokens, which are on Solana Mainnet. title="Compress SPL Token Accounts" icon="chevron-right" color="#0066ff" - href="/compressed-tokens/guides/compress-spl-token-account" + href="https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/compress.ts" horizontal /> -# Get Started +## RPC Methods - - - +The Photon API provides ZK Compression methods that extend default Solana JSON RPC API. +Detailed documentation can be found [here](https://www.helius.dev/docs/api-reference/zk-compression). -### Install dependencies +## Guides - - +The SDK for compressed tokens can be used but is not maintained. +Use [Light Token](/light-token/welcome) for other purposes than token distribution or storage of inactive tokens. - +| | | +|---------|------| +| Compressed token cookbook | [GitHub](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) | +| Token distribution | [GitHub](https://github.com/Lightprotocol/examples-zk-compression/tree/main/example-token-distribution) | +| Web client | [GitHub](https://github.com/Lightprotocol/examples-zk-compression/tree/main/example-web-client) | -### Set up your developer environment - - - - - - - - - - - - - ### Basic Guides - - +--- - - ### Advanced Guides - - +## Didn't find what you were looking for? - + +Reach out! [Telegram](https://t.me/swen_light) | [email](mailto:support@lightprotocol.com) | [Discord](https://discord.com/invite/7cJ8BhAXhu) + diff --git a/home.mdx b/home.mdx index c93c4494..5d8b9d22 100644 --- a/home.mdx +++ b/home.mdx @@ -101,25 +101,24 @@ while being more CU efficient than SPL on hot paths.
- -## Token Distribution - +## PDA Accounts - - Distribute tokens on Solana 5000x cheaper. + + Solana PDAs with sponsored rent-exemption that can be implemented with minimal code changes. + Use like any other PDA, e.g. in your DeFi program. - - Merkle distributor and simple claim programs for airdrops with claim. + + Compressed PDAs to store user, app, or other infrequently accessed state without rent-exemption. Fully compatible with existing Solana programs, but requires custom logic. - -## Compressed PDA Toolkits - - Introduction to compressed PDAs to store user, app, or other infrequently accessed state without rent-exemption. - +## Other Use Cases + + + Distribute tokens on Solana 5000x cheaper. Merkle distributor and simple claim programs for airdrops with claim. + Credential system for KYC verification, professional badges, and compliance credentials in minutes. @@ -133,13 +132,13 @@ while being more CU efficient than SPL on hot paths. -Download agent skill or view [skill.md](https://www.zkcompression.com/skill.md): +Install orchestrator agent skill or view [skill.md](https://www.zkcompression.com/skill.md): ```bash npx skills add https://zkcompression.com ``` -Dedicated agent skills: +Install or view dedicated agent skills: https://github.com/Lightprotocol/skills @@ -215,9 +214,9 @@ codex mcp add deepwiki -- npx -y mcp-remote@latest https://mcp.deepwiki.com/mcp Learn core concepts of the Light token program and ZK Compression Core. - - Debug common errors and issues. - + + Syntax reference for #[light_account] constraints for PDA, mint, token, and associated token accounts. + RPC endpoints and addresses for programs, Merkle trees, and other accounts. diff --git a/light-token/light-pda.mdx b/light-token/light-pda.mdx index a1cc4505..efa6395d 100644 --- a/light-token/light-pda.mdx +++ b/light-token/light-pda.mdx @@ -1,6 +1,5 @@ --- title: "Light PDA" -sidebarTitle: "Integration Guide" description: "Create PDA accounts with sponsored rent-exemption for Anchor programs. Works with your existing Anchor implementations." --- @@ -11,7 +10,7 @@ Programs create them using Anchor `#[account(init)]` with `#[light_account(init) | | Regular PDA | Light-PDA | |------------------|----------------------|-----------------| -| 100-byte account | ~1,600,000 lamports | 10,000 lamports | +| 100-byte account | ~1,600,000 lamports | ~11,500 lamports | ## What changes diff --git a/light-token/pda-overview.mdx b/light-token/pda-overview.mdx new file mode 100644 index 00000000..3f845884 --- /dev/null +++ b/light-token/pda-overview.mdx @@ -0,0 +1,44 @@ +--- +title: "PDA accounts" +sidebarTitle: "Overview" +description: "Overview to Light-PDAs (Solana accounts with sponsored rent-exemption) and compressed PDAs (compressed accounts without rent-exemption)." +--- +import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx"; + +## Light-PDA + +Light-PDAs are Solana PDAs with sponsored rent-exemption created using Anchor `#[account(init)]` with `#[light_account(init)]`. +Can be implemented with minimal code changes to your existing Solana program and leaves program logic mostly untouched. + +| | Regular PDA | Light-PDA | +|------------------|----------------------|-----------------| +| 100-byte account | ~1,600,000 lamports | ~11,500 lamports | + + + + + +- Standard Anchor account type (`Account<'info, T>`) +- Reads, updates, and closes are unchanged +- Inactive accounts auto-compress; clients load them back when needed +- Use like any other PDA, e.g. in your DeFi program. + + + +--- + +## Compressed PDA + +Compressed PDAs are compressed accounts with an address. +Programs invoke the Light System program to create and update compressed accounts, instead of the System program. +Fully compatible with existing Solana programs, but requires custom logic. + +| | Regular PDA | Compressed PDA | +|------------------|----------------------|-----------------| +| 100-byte account | ~1,600,000 lamports | 15,000 lamports | + +- Derived using a program address and seed, like regular PDAs +- Compressed state requires a validity proof for every read and write (fetched by client from RPC that supports ZK Compression, such as Helius and Triton) +- Use for app and user state, or other accounts that are infrequently accessed + + \ No newline at end of file diff --git a/references/terminology.mdx b/references/terminology.mdx index 526cf15c..362e0d8a 100644 --- a/references/terminology.mdx +++ b/references/terminology.mdx @@ -1,8 +1,11 @@ --- title: "Terminology" -description: "Overview to terminology related to ZK Compression and Solana" +description: "Overview of terminology related to ZK Compression, Light Token, and Solana" --- +import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx"; +import CompressibleVsSolanaRent from "/snippets/compressible-vs-solana-rent.mdx"; + ## Account An entry in the Solana ledger that holds data or executable program code, stored on chain. @@ -15,7 +18,7 @@ There are different kinds of accounts, including ## Account Compression Program -Light Protocol's program that implements state and address trees for ZK Compression. The program provides the underlying Merkle tree infrastructure used by the Light System Program to manage compressed account state transitions. +Light Protocol's program that implements state and address trees for ZK Compression. The Light System Program uses the Account Compression Program's Merkle tree infrastructure to store compressed account state transitions. **Source**: https://github.com/Lightprotocol/light-protocol/tree/main/programs/account-compression @@ -36,54 +39,46 @@ Two address tree versions are currently supported: A computer program that accesses the Solana server network [cluster](https://solana.com/docs/core/transactions#cluster). -## [**Cluster**](https://solana.com/docs/references/terminology#cluster) +## [Cluster](https://solana.com/docs/references/terminology#cluster) A set of [validators](https://solana.com/docs/references/terminology#validator) maintaining a single [ledger](https://solana.com/docs/references/terminology#ledger). -## Compressed PDA +## Cold account -Compressed accounts with an address stored in an address Merkle tree. -Full Solana PDA functionality and composability without rent-exemption. +A Light Token account, Light Token mint, or Light-PDA that has been compressed after extended inactivity. The account's state is cryptographically preserved on the Solana ledger as a compressed account. On-chain lookups return `is_initialized: false`. Clients call `create_load_instructions` to reinstate the account. + +## Compressible account + +A Solana account (Light Token account, Light Token mint, or Light-PDA) that automatically compresses when its rent balance drops below threshold. Forester nodes execute the compression. The account can be loaded back when accessed again. ## Compressed account A data structure that holds arbitrary data, represented as a 32-byte hash stored in a leaf of a state Merkle tree. Compressed accounts do not require a rent exempt balance upon creation. -## Compressed Account hash - -A 32-byte identifier uniquely that represents a compressed account's state, stored in a state tree. +## Compressed account hash -## Token mint +A 32-byte identifier that uniquely represents a compressed account's state, stored in a state tree. -An SPL token mint uniquely represents a token on the Solana network and stores global metadata about the token, including `mint_authority`, `supply`, and `decimals`. +## Compressed PDA -SPL tokens can be compressed if the mint has a token pool account set up. Anyone can create a token pool PDA for any given SPL mint. +Compressed accounts with an address stored in an address Merkle tree. +Full Solana PDA functionality and composability without rent-exemption. -## SPL Interface PDA Account +[Docs](/compressed-pdas/overview) -SPL interface PDA account that holds SPL tokens corresponding to compressed tokens and Light Tokens in circulation. -Owned by the Light Token Program's CPI authority PDA. +## Compressed token -## Compressed Token +An SPL token stored as a compressed account hash in a state tree. Compressed tokens incur no rent and do not require a token account per holder. -An SPL token in compressed form. -Compressed tokens do not require an associated token account per holder. +[Docs](/compressed-tokens/overview) -## Compressed Token account +## Compressed token account -An account type in the Light Token Program to store information about an individual's ownership of a specific token (mint). +A compressed account that stores a token balance for a specific mint. Compressed token accounts do not require a rent exempt balance upon creation. Compressed token accounts are compressed accounts that do not need an address. -## Light Token Program - -Light Protocol's SPL-compatible token program that enables compression and decompression of token accounts. The program enforces SPL token layout standards and allows for arbitrary transitions between compressed and regular format. - -## [**Compute units**](https://solana.com/docs/references/terminology#compute-units) - -The smallest unit of measure for consumption of computational resources of the transactions on the Solana blockchain. - -## [**Compute unit budget**](https://solana.com/docs/references/terminology#compute-budget) +## [Compute unit budget](https://solana.com/docs/references/terminology#compute-budget) The maximum number of [compute units](https://solana.com/docs/references/terminology#compute-units) consumed per transaction. @@ -97,6 +92,10 @@ The total amount of compute units that all transactions in a single Solana block The maximum compute units that can be used to modify a single account within a block - the _write lock limit -_ is currently set at 12 million CU. +## [Compute units](https://solana.com/docs/references/terminology#compute-units) + +The smallest unit of measure for consumption of computational resources of the transactions on the Solana blockchain. + ## [Cross-program invocation (CPI)](https://solana.com/docs/core/transactions#cross-program-invocation-cpi) A call from one [program](https://solana.com/docs/core/transactions#onchain-program) to another. @@ -105,7 +104,7 @@ A call from one [program](https://solana.com/docs/core/transactions#onchain-prog ## Decompression -The process of converting a compressed to a regular Solana account. SPL tokens are withdrawn from the token pool to an Associated Token Account and compressed token accounts are invalidated. +The process of converting a compressed account to a regular Solana account. For token decompression, SPL tokens are released from the SPL interface PDA to an associated token account, and the compressed token account is invalidated. ## Forester node / Forester @@ -117,19 +116,23 @@ A zero-knowledge SNARK that produces constant-size proofs using bilinear pairing ZK Compression uses Groth16 to generate 128 byte validity proofs to verify compressed account state transitions against the on-chain root. -## [**Hash**](https://solana.com/docs/references/terminology#hash) +## [Hash](https://solana.com/docs/references/terminology#hash) A hash is a digital fingerprint of a sequence of bytes representing arbitrary data, while requiring far less storage space than the original data. +## Hot account + +A Light Token account, Light Token mint, or Light-PDA that is active on-chain with a rent-exempt balance. Programs interact only with hot accounts. Clients call `create_load_instructions` to reinstate cold accounts before use. + ## Indexer -A service that tracks state changes of compressed accounts on the Solana ledger and provides RPC APIs for querying compressed accounts and generating validity proofs. +A service that tracks state changes of compressed accounts on the Solana ledger. The indexer exposes RPC APIs for querying compressed accounts and generating validity proofs. The ZK Compression indexer is named Photon and is maintained by Helius Labs. **Source**: https://github.com/helius-labs/photon -## [**Instruction**](https://solana.com/docs/references/terminology#instruction) +## [Instruction](https://solana.com/docs/references/terminology#instruction) A call to invoke a specific [instruction handler](https://solana.com/docs/references/terminology#instruction-handler) in a [program](https://solana.com/docs/references/terminology#program). @@ -141,6 +144,21 @@ For example, compressed accounts are created or updated with the `InvokeCpiInstr The numerical position (u32) of a compressed account within a state tree, used for Merkle proof generation. +## Ledger + +The ledger is an immutable historical record of all Solana transactions signed by clients since the genesis block. + +A helpful analogy to differentiate Solana ledger and state: + +- Ledger is the entire bank statement history. +- State is the current account balance, derived from all transactions in the bank statement history. + +## Light-PDA + +A Solana PDA with sponsored rent-exemption. Programs create Light-PDAs using Anchor `#[account(init)]` with `#[light_account(init)]`. Compresses automatically after extended inactivity; clients load the account back when it's accessed again. Program logic does not change for reads, updates, or closes. Only the init instruction and state struct require additions. + +[Docs](/light-token/light-pda) | [Overview](/light-token/pda-overview) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter) + ## Light System Program ZK Compression's core program that validates compressed account state transitions by verifying validity proofs and managing compressed state changes. @@ -149,24 +167,43 @@ The program enforces compressed account layout with ownership and sum checks, an **Source**: https://github.com/Lightprotocol/light-protocol/tree/main/programs/system -## **Ledger** +## Light Token -The ledger is an immutable historical record of all Solana transactions signed by clients since the genesis block. +A token standard that reduces the cost of mint and token accounts by 200x compared to SPL. Functionally equivalent to SPL but stores accounts more efficiently. The Light Token SDK API is a superset of the SPL-token API. -A helpful analogy to differentiate Solana ledger and state: +Light Token accounts exist in two states: hot (active on-chain) and cold (compressed after inactivity). The Light Token Program sponsors rent-exemption for account creation. -- Ledger is the entire bank statement history. -- State is the current account balance, derived from all transactions in the bank statement history. +[Docs](/light-token/welcome) | [Example](https://github.com/Lightprotocol/examples-light-token) -## Merkle tree +## Light Token account -A tree data structure to allow for cryptographic verification of the integrity of all leaves in a tree. +A Solana account that holds a token balance for a specific mint (SPL, Token 2022, or Light Token). The Light Token Program sponsors the rent-exemption cost. Follows the same layout as SPL token accounts. Compresses automatically after extended inactivity and can be loaded back when accessed. -Each leaf on a Merkle tree is a hash of that leaf's data. A Merkle tree compresses data by hashing pairs of data repeatedly into a single root hash, starting from the lowest level. Only this root hash is stored on chain. On Solana, this process is called state compression. +[Docs](/light-token/cookbook/create-token-account) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-token-account) -## Merkle tree account +## Light Token associated token account -The public key of the on-chain Merkle tree account used in ZK Compression. This identifier references the state tree that stores compressed account hashes. +An associated token account created by the Light Token Program. The address is deterministically derived from the owner's address, Light Token Program ID, and mint address. Holds token balances of SPL, Token 2022, or Light Token mints with sponsored rent-exemption. + +[Docs](/light-token/cookbook/create-ata) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-associated-token-account) + +## Light Token mint + +An on-chain mint account owned by the Light Token Program. Functionally equivalent to an SPL mint but with sponsored rent-exemption. Stores a compressed address in an address Merkle tree at creation to preserve mint state when the account compresses. + +[Docs](/light-token/cookbook/create-mint) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-mint) | [Source Code](https://github.com/Lightprotocol/light-protocol/blob/main/sdk-libs/token-sdk/src/instruction/create_mint.rs) + +## Light Token Program + +Light Protocol's SPL-compatible token program. The Light Token Program compresses and decompresses token accounts, sponsors rent-exemption, and enforces SPL token layout standards. + +[Source Code](https://github.com/Lightprotocol/light-protocol/tree/main/programs/compressed-token) + +## Load + +Reinstates a compressed account back to active on-chain state. `loadAta` unifies token balances from compressed tokens, SPL, and Token 2022 into a single Light Token associated token account. Returns `null` if there's nothing to load (idempotent). Creates the associated token account if it doesn't exist. + +[Docs](/light-token/cookbook/load-ata) | [Source Code](https://github.com/Lightprotocol/light-protocol/blob/0c4e2417b2df2d564721b89e18d1aad3665120e7/js/compressed-token/src/v3/actions/load-ata.ts) ## Merkle proof @@ -174,6 +211,16 @@ A cryptographic proof consisting of sibling node hashes required to verify that ZK Compression encodes Merkle proofs into zero-knowledge proofs (validity proofs). These verify compressed account operations with a constant 128-byte size without exposing the underlying variable-size Merkle proof data. +## Merkle tree + +A tree data structure to allow for cryptographic verification of the integrity of all leaves in a tree. + +Each leaf on a Merkle tree is a hash of that leaf's data. A Merkle tree compresses data by hashing pairs of data repeatedly into a single root hash, starting from the lowest level. Only this root hash is stored on chain. On Solana, this process is called state compression. + +## Merkle tree account + +The public key of the on-chain Merkle tree account used in ZK Compression. This identifier references the state tree that stores compressed account hashes. + ## Nullification The process of marking compressed accounts as spent to prevent double-spending. @@ -184,37 +231,37 @@ When compressed accounts are used as inputs in transactions, their previous stat A queue where compressed accounts hashes used as input for transactions are temporarily stored to prevent double spending. A Forester node empties the queue by inserting queue elements into a state Merkle tree. -## [**Program**](https://solana.com/docs/references/terminology#onchain-program) - -Programs run executable code similar to smart contracts on other blockchains with optimizations specific to Solana. - -Solana programs key characteristics include: - -- Solana programs are stateless and do not store state internally. Separate accounts store state for programs to execute on, such as program, user or token data. This makes Solana's account model [different from Ethereum's](https://solana.com/news/evm-to-svm). -- Programs are typically written in Rust. -- Programs interpret the [instructions](https://solana.com/docs/references/terminology#instruction) sent inside of each [transaction](https://solana.com/docs/references/terminology#transaction) to read and modify accounts over which it has control, hence update state. - ## Parallelism The ability of the SVM to execute multiple transactions simultaneously, as long as they modify different regular and/or compressed accounts. -## [**Program derived addresses (PDA)**](https://solana.com/docs/references/terminology#program-derived-account-pda) +## Poseidon hash -PDAs are special account addresses derived deterministically using optional seeds, a bump seed, and a program ID. +A cryptographic hash function optimized for zero-knowledge proof systems that works natively with finite field arithmetic. -They are off the Ed25519 curve, meaning they have no private key. The PDA itself, once derived, is 32 bytes, matching a regular public key. +The Poseidon hash is designed to minimize computational complexity in ZK circuits. ZK Compression uses Poseidon hashes to generate the account hashes stored as leaves in state trees. -## [**Prioritization fee**](https://solana.com/docs/references/terminology#prioritization-fee) +## [Prioritization fee](https://solana.com/docs/references/terminology#prioritization-fee) An additional fee user can specify in the compute budget [instruction](https://solana.com/docs/references/terminology#instruction) to prioritize their [transactions](https://solana.com/docs/references/terminology#transaction). The priority fee is derived from the compute unit limit and the compute unit price. The price per compute unit set by the user in micro-lamports (1 lamport = 1,000,000 micro-lamports), rounded up to the nearest lamport. -## Poseidon hash +## [Program](https://solana.com/docs/references/terminology#onchain-program) -A cryptographic hash function optimized for zero-knowledge proof systems that works natively with finite field arithmetic. +Programs run executable code similar to smart contracts on other blockchains with optimizations specific to Solana. -The Poseidon hash is designed to minimize computational complexity in ZK circuits. ZK Compression uses Poseidon hashes to generate the account hashes stored as leaves in state trees. +Solana programs key characteristics include: + +- Solana programs are stateless and do not store state internally. Separate accounts store state for programs to execute on, such as program, user or token data. This makes Solana's account model [different from Ethereum's](https://solana.com/news/evm-to-svm). +- Programs are typically written in Rust. +- Programs interpret the [instructions](https://solana.com/docs/references/terminology#instruction) sent inside of each [transaction](https://solana.com/docs/references/terminology#transaction) to read and modify accounts over which it has control, hence update state. + +## [Program derived addresses (PDA)](https://solana.com/docs/references/terminology#program-derived-account-pda) + +PDAs are special account addresses derived deterministically using optional seeds, a bump seed, and a program ID. + +They are off the Ed25519 curve, meaning they have no private key. The PDA itself, once derived, is 32 bytes, matching a regular public key. ## Proof verification @@ -224,7 +271,7 @@ The on-chain process of validating zero-knowledge proofs to confirm the correctn A fee paid in SOL for the creation of [Accounts](https://solana.com/docs/references/terminology#account) to store data on the blockchain, tied to account size. When accounts do not have enough balance to pay rent, they may be Garbage Collected. -## [**Rent exempt**](https://solana.com/docs/references/terminology#rent-exempt) +## [Rent exempt](https://solana.com/docs/references/terminology#rent-exempt) An account that maintains a minimum lamport balance proportional to the amount of data stored on the account. @@ -238,6 +285,14 @@ The minimum balance is paid by the creator and is calculated as follows: Minimum Rent Balance = 2 × 0.00000348 SOL/byte/year × Account Size (Bytes) ``` +## Rent sponsorship + + + + + + + ## Remote Procedure Calls (RPC) A bridge between users (or applications) and the blockchain to facilitate interactions and data retrieval. @@ -249,22 +304,26 @@ The [ZK Compression RPC API](https://www.zkcompression.com/developers/json-rpc-m here](/api-reference/json-rpc-methods/overview). -## [**Smart contract**](https://solana.com/docs/references/terminology#smart-contract) +## [Smart contract](https://solana.com/docs/references/terminology#smart-contract) Smart contracts on Solana are called programs with key characteristics and optimizations. -## Solana Account Model +## Solana account model The native framework to store and manage data on the Solana blockchain. -Solana's Account Model separates program logic from state to optimize for parallel and faster transactions. Separate accounts store state for programs to execute on, such as program, user or token data. This makes Solana's Account Model [different from Ethereum's](https://solana.com/news/evm-to-svm). +Solana's account model separates program logic from state to optimize for parallel and faster transactions. Separate accounts store state for programs to execute on, such as program, user or token data. This makes Solana's account model [different from Ethereum's](https://solana.com/news/evm-to-svm). -ZK Compression extends Solana's Account Model with Compressed Accounts. +ZK Compression extends Solana's account model with compressed accounts. -## [**Solana Program Library (SPL)**](https://solana.com/docs/references/terminology#solana-program-library-spl) +## [Solana Program Library (SPL)](https://solana.com/docs/references/terminology#solana-program-library-spl) A [library of programs](https://spl.solana.com/) on Solana such as spl-token that facilitates tasks such as creating and using tokens. +## SPL interface PDA + +A PDA owned by the Light Token Program's CPI authority that holds SPL tokens corresponding to compressed tokens and Light Token balances in circulation. Each SPL interface PDA is associated with a specific mint. + ## State A snapshot representing the current status of all accounts and programs on Solana. @@ -273,23 +332,6 @@ The state is derived from the ledger by sequentially applying every transaction. State is kept in RAM by validators for transaction validation. -## State root - -The root hash of a Merkle tree that serves as a cryptographic fingerprint representing all compressed accounts in the tree. - -State roots are stored on-chain and used by the Light System Program to verify validity proofs during compressed account operations. Each state root represents the complete state of compressed accounts at a specific point in time. - -## State tree - -A Merkle tree that stores compressed account hashes as leaf nodes. - -State trees organize compressed account data into a binary tree structure where each parent node is the hash of its two children nodes. The tree's root hash is stored on-chain as a cryptographic fingerprint representing all accounts in the tree. - -Two state tree versions with different proof mechanisms are currently supported: - -- **V1 state trees**: Always require the full 128-byte validity proof. With a depth of 26, a single V1 state tree stores approximately 67 million compressed accounts. -- **V2 batched state trees**: Support `prove_by_index` optimization that verifies account existence with one byte instead of 128 bytes, optimizing compute unit consumption by up to 70%. - ## State compression A process to lower the amount of data stored on chain using Merkle trees. @@ -307,17 +349,34 @@ The process of state compression involves the following steps: here](https://solana.com/developers/courses/state-compression/generalized-state-compression). +## State root + +The root hash of a Merkle tree that serves as a cryptographic fingerprint representing all compressed accounts in the tree. + +State roots are stored on-chain and used by the Light System Program to verify validity proofs during compressed account operations. Each state root represents the complete state of compressed accounts at a specific point in time. + +## State tree + +A Merkle tree that stores compressed account hashes as leaf nodes. + +State trees organize compressed account data into a binary tree structure where each parent node is the hash of its two children nodes. The tree's root hash is stored on-chain as a cryptographic fingerprint representing all accounts in the tree. + +Two state tree versions with different proof mechanisms are currently supported: + +- **V1 state trees**: Always require the full 128-byte validity proof. With a depth of 26, a single V1 state tree stores approximately 67 million compressed accounts. +- **V2 batched state trees**: Support `prove_by_index` optimization that verifies account existence with one byte instead of 128 bytes, optimizing compute unit consumption by up to 70%. + ## Token account A token account is an account type in Solana's Token Programs that stores information about an individual's ownership of a specific token (mint). Each token account is associated with a single mint and tracks details like the token balance and owner. -## [**Token mint**](https://solana.com/docs/references/terminology#token-mint) +## [Token mint](https://solana.com/docs/references/terminology#token-mint) A [mint account](https://solana.com/docs/tokens/basics/create-mint) is an account type in Solana's Token Programs that can produce (or 'mint') tokens. -Different tokens are distinguished by their unique token mint addresses. Token mints uniquely represents a token on the network and stores global metadata about the token, including the `mint_authority`, supply, and decimals. +Different tokens are distinguished by their unique token mint addresses. Token mints uniquely represent a token on the network and store global metadata about the token, including the `mint_authority`, supply, and decimals. SPL tokens can be compressed if the mint has an SPL interface PDA. -## [**Transaction**](https://solana.com/docs/references/terminology#transaction) +## [Transaction](https://solana.com/docs/references/terminology#transaction) One or more [instructions](https://solana.com/docs/references/terminology#instruction) signed by a [client](https://solana.com/docs/references/terminology#client) using one or more [keypairs](https://solana.com/docs/references/terminology#keypair) and executed atomically with only two possible outcomes: success or failure. @@ -331,7 +390,13 @@ The _validity proof_ is - constant 128 byte in size (other than Merkle proofs with varying proof size), fitting well in Solana's 1232 byte transaction limit - verified against the respective on chain fingerprint to ensure the provided data was previously emitted -- provided and generated by indexers that support the [ZK Compression RPC API](https://www.zkcompression.com/developers/json-rpc-methods) which extend Solana's [JSON RPC API](https://solana.com/docs/rpc) to interact with compressed accounts. . +- provided and generated by indexers that support the [ZK Compression RPC API](https://www.zkcompression.com/developers/json-rpc-methods) which extend Solana's [JSON RPC API](https://solana.com/docs/rpc) to interact with compressed accounts. + +## Wrap and unwrap + +**Wrap** moves tokens from an SPL or Token 2022 account into a Light Token associated token account. **Unwrap** moves tokens from a Light Token associated token account back to an SPL or Token 2022 account. Use wrap/unwrap to interact with applications that only support SPL or Token 2022. + +[Docs](/light-token/cookbook/wrap-unwrap) | [Source Code](https://github.com/Lightprotocol/light-protocol/blob/0c4e2417b2df2d564721b89e18d1aad3665120e7/js/compressed-token/src/v3/actions/wrap.ts) ## Zero-knowledge proof (ZKP) @@ -342,12 +407,6 @@ ZK Compression uses a Groth16 SNARK zk proof - for its constant _validity_ proof size, to ensures the integrity of many compressed accounts, not for private or confidential transactions, and - to store data in zk friendly data structures. Applications on Solana can prove custom off chain computations over zk compressed state (native zk compute). -## ZK-SNARK - -Zero-Knowledge Succinct Non-Interactive Arguments of Knowledge, a cryptographic proof system that enables proving knowledge of information without revealing the information itself. - -zk-SNARKs produce constant-size proofs that can be verified efficiently without interaction between prover and verifier. ZK Compression uses the Groth16 zk-SNARK construction to generate validity proofs for compressed account state transitions. - ## ZK Compression A generalized compression framework to compress and verify arbitrary data with zero-knowledge proofs, to @@ -355,3 +414,9 @@ A generalized compression framework to compress and verify arbitrary data with z - enable the Compressed Account Model, the rent-free equivalent to Solana's Account Model, - solve Solana's state growth problem, and - build a foundation for native zk compute. + +## ZK-SNARK + +Zero-Knowledge Succinct Non-Interactive Arguments of Knowledge. A cryptographic proof system where a prover demonstrates knowledge of information without revealing the information itself. + +zk-SNARKs produce constant-size proofs that can be verified efficiently without interaction between prover and verifier. ZK Compression uses the Groth16 zk-SNARK construction to generate validity proofs for compressed account state transitions. diff --git a/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx b/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx index ac09b01c..13e4fd21 100644 --- a/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx +++ b/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx @@ -1,6 +1,6 @@ | Guide | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | -| [Create an Airdrop without Claim](/compressed-tokens/advanced-guides/airdrop) | ZK Compression is the most efficient way to distribute SPL tokens. Distribute via Webapp or customize with claim. | +| [Create an Airdrop without Claim](/compressed-tokens/airdrop) | ZK Compression is the most efficient way to distribute SPL tokens. Distribute via Webapp or customize with claim. | | [Combine Instructions in One Transaction](/compressed-tokens/advanced-guides/how-to-combine-operations-in-one-transaction) | Execute multiple token instructions within a single transaction | | [For Wallet Applications](/compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens) | Add compressed token support in your wallet application | | [Use Token-2022 with Compression](/compressed-tokens/advanced-guides/use-token-2022-with-compression) | Create compressed Token-2022 mints with metadata and other extensions | From 82206b9ece11b4026fedd1893cba64eee93d61c7 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Fri, 13 Feb 2026 16:51:07 +0000 Subject: [PATCH 13/27] update terminology --- references/terminology.mdx | 135 ++++++++++++++++++++++++++++++++----- 1 file changed, 119 insertions(+), 16 deletions(-) diff --git a/references/terminology.mdx b/references/terminology.mdx index 362e0d8a..44aceaf9 100644 --- a/references/terminology.mdx +++ b/references/terminology.mdx @@ -20,9 +20,34 @@ There are different kinds of accounts, including Light Protocol's program that implements state and address trees for ZK Compression. The Light System Program uses the Account Compression Program's Merkle tree infrastructure to store compressed account state transitions. - - **Source**: https://github.com/Lightprotocol/light-protocol/tree/main/programs/account-compression - +> **Program ID**: `compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq` | [Source](https://github.com/Lightprotocol/light-protocol/tree/main/programs/account-compression) + +## Account Compression Authority + +A PDA that signs CPI calls from the Light System Program to the Account Compression Program. Derived from the Light System Program ID with seed `b'cpi_authority'`. + +> **Address**: `HZH7qSLcpAeDqCopVU4e5XkhT9j3JFsQiq8CmruY3aru` + +## Agent skills + +Folders of instructions, scripts, and resources that AI agents can discover and use to build on Light Protocol more accurately and efficiently. +Light Protocol provides agent skills for rent-free Solana development: Light-PDA, token and mint accounts. +Skills for compressed PDAs and more are in development. + +| Use case | Skill | +|----------|-------| +| Build DeFi programs (AMMs, vaults, lending) with Anchor or Pinocchio | [defi-program](https://github.com/Lightprotocol/skills/tree/main/skills/defi-program) | +| Integrate rent-free markets into routers and aggregators | [defi-router](https://github.com/Lightprotocol/skills/tree/main/skills/defi-router) | +| Stream account state via Laserstream gRPC | [data-streaming](https://github.com/Lightprotocol/skills/tree/main/skills/data-streaming) | +| Wallets and payment flows with Light Token. Optional nullifier to prevent your on-chain instruction from being executed more than once. | [payments-and-wallets](https://github.com/Lightprotocol/skills/tree/main/skills/payments-and-wallets) | +| Airdrops, DePIN, token distribution | [airdrop](https://github.com/Lightprotocol/skills/tree/main/skills/airdrop) | +| Anti-double-spend nullifiers for privacy-preserving ZK programs | [zk-nullifier](https://github.com/Lightprotocol/skills/tree/main/skills/zk-nullifier) | +| Testing programs and clients on localnet, devnet, mainnet | [testing](https://github.com/Lightprotocol/skills/tree/main/skills/testing) | +| Help with debugging and questions via DeepWiki MCP | [ask-mcp](https://github.com/Lightprotocol/skills/tree/main/skills/ask-mcp) | + +Built on [Anthropic's Skills](https://github.com/anthropics/skills) and the [Agent Skills Specification](https://agentskills.io). + +> [Source Code](https://github.com/Lightprotocol/skills) | [Claude plugin](https://github.com/Lightprotocol/skills/tree/main/.claude-plugin) | [OpenClaw plugin](https://github.com/Lightprotocol/skills/blob/main/openclaw.plugin.json) ## Address tree @@ -35,6 +60,17 @@ Two address tree versions are currently supported: - **V1 address trees**: Height 26 (~67 million addresses) - **V2 batched address trees**: Height 40 (~1 trillion addresses), optimizing compute unit consumption by up to 70%. V2 is currently on Devnet. +| Version | Address Tree | Address Queue | +|:--------|:-------------|:--------------| +| V2 | `amt2kaJA14v3urZbZvnc5v2np8jqvc4Z8zDep5wbtzx` | — | +| V1 (deprecated) | `amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2` | `aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F` | + +## Address queue + +A queue used in V1 address trees to buffer new addresses before Forester nodes insert them into the address tree. V2 address trees do not use a separate queue. + +> **Address (V1)**: `aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F` + ## [Client](https://solana.com/docs/core/transactions#client) A computer program that accesses the Solana server network [cluster](https://solana.com/docs/core/transactions#cluster). @@ -64,13 +100,13 @@ A 32-byte identifier that uniquely represents a compressed account's state, stor Compressed accounts with an address stored in an address Merkle tree. Full Solana PDA functionality and composability without rent-exemption. -[Docs](/compressed-pdas/overview) +> [Docs](/compressed-pdas/overview) ## Compressed token An SPL token stored as a compressed account hash in a state tree. Compressed tokens incur no rent and do not require a token account per holder. -[Docs](/compressed-tokens/overview) +> [Docs](/compressed-tokens/overview) ## Compressed token account @@ -102,6 +138,16 @@ A call from one [program](https://solana.com/docs/core/transactions#onchain-prog For more information, see [calling between programs](https://solana.com/docs/core/cpi). +## CPI context account + +An account passed in transactions that stores intermediate CPI state for compressed account operations. Each state tree has a dedicated CPI context account. + +Addresses are listed under the state tree entry. + +## CPI signer + +A PDA that signs CPI calls from your program to the Light System Program. Verified by the Light System Program during CPI. Derived from your program ID using `derive_light_cpi_signer`. + ## Decompression The process of converting a compressed account to a regular Solana account. For token decompression, SPL tokens are released from the SPL interface PDA to an associated token account, and the compressed token account is invalidated. @@ -157,7 +203,7 @@ A helpful analogy to differentiate Solana ledger and state: A Solana PDA with sponsored rent-exemption. Programs create Light-PDAs using Anchor `#[account(init)]` with `#[light_account(init)]`. Compresses automatically after extended inactivity; clients load the account back when it's accessed again. Program logic does not change for reads, updates, or closes. Only the init instruction and state struct require additions. -[Docs](/light-token/light-pda) | [Overview](/light-token/pda-overview) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter) +> [Docs](/light-token/light-pda) | [Overview](/light-token/pda-overview) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter) ## Light System Program @@ -165,7 +211,7 @@ ZK Compression's core program that validates compressed account state transition The program enforces compressed account layout with ownership and sum checks, and is invoked to create and write to compressed accounts and PDAs. -**Source**: https://github.com/Lightprotocol/light-protocol/tree/main/programs/system +> **Program ID**: `SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7` | [Source](https://github.com/Lightprotocol/light-protocol/tree/main/programs/system) ## Light Token @@ -173,37 +219,49 @@ A token standard that reduces the cost of mint and token accounts by 200x compar Light Token accounts exist in two states: hot (active on-chain) and cold (compressed after inactivity). The Light Token Program sponsors rent-exemption for account creation. -[Docs](/light-token/welcome) | [Example](https://github.com/Lightprotocol/examples-light-token) +Different from ZK Compression, interactions with Light Token accounts do not require a validity proof for interactions. +ZK Compression is used under the hood for inactive token accounts (cold state). + +> [Docs](/light-token/welcome) | [Example](https://github.com/Lightprotocol/examples-light-token) ## Light Token account A Solana account that holds a token balance for a specific mint (SPL, Token 2022, or Light Token). The Light Token Program sponsors the rent-exemption cost. Follows the same layout as SPL token accounts. Compresses automatically after extended inactivity and can be loaded back when accessed. -[Docs](/light-token/cookbook/create-token-account) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-token-account) +> [Docs](/light-token/cookbook/create-token-account) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-token-account) ## Light Token associated token account An associated token account created by the Light Token Program. The address is deterministically derived from the owner's address, Light Token Program ID, and mint address. Holds token balances of SPL, Token 2022, or Light Token mints with sponsored rent-exemption. -[Docs](/light-token/cookbook/create-ata) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-associated-token-account) +> [Docs](/light-token/cookbook/create-ata) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-associated-token-account) ## Light Token mint An on-chain mint account owned by the Light Token Program. Functionally equivalent to an SPL mint but with sponsored rent-exemption. Stores a compressed address in an address Merkle tree at creation to preserve mint state when the account compresses. -[Docs](/light-token/cookbook/create-mint) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-mint) | [Source Code](https://github.com/Lightprotocol/light-protocol/blob/main/sdk-libs/token-sdk/src/instruction/create_mint.rs) +> [Docs](/light-token/cookbook/create-mint) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-mint) | [Source Code](https://github.com/Lightprotocol/light-protocol/blob/main/sdk-libs/token-sdk/src/instruction/create_mint.rs) ## Light Token Program Light Protocol's SPL-compatible token program. The Light Token Program compresses and decompresses token accounts, sponsors rent-exemption, and enforces SPL token layout standards. -[Source Code](https://github.com/Lightprotocol/light-protocol/tree/main/programs/compressed-token) +> **Program ID**: `cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m` | [Source](https://github.com/Lightprotocol/light-protocol/tree/main/programs/compressed-token) -## Load +## Load associated token account Reinstates a compressed account back to active on-chain state. `loadAta` unifies token balances from compressed tokens, SPL, and Token 2022 into a single Light Token associated token account. Returns `null` if there's nothing to load (idempotent). Creates the associated token account if it doesn't exist. -[Docs](/light-token/cookbook/load-ata) | [Source Code](https://github.com/Lightprotocol/light-protocol/blob/0c4e2417b2df2d564721b89e18d1aad3665120e7/js/compressed-token/src/v3/actions/load-ata.ts) +> [Docs](/light-token/cookbook/load-ata) | [Source Code](https://github.com/Lightprotocol/light-protocol/blob/0c4e2417b2df2d564721b89e18d1aad3665120e7/js/compressed-token/src/v3/actions/load-ata.ts) + +## Lookup table + +A Solana [address lookup table](https://solana.com/docs/advanced/lookup-tables) that reduces transaction size by referencing accounts by index instead of full public key. Light Protocol provides pre-initialized lookup tables covering program IDs and protocol accounts. + +| Network | Address | +|:--------|:--------| +| Mainnet | `9NYFyEqPkyXUhkerbGHXUXkvb4qpzeEdHuGpgbgpH1NJ` | +| Devnet | `qAJZMgnQJ8G6vA3WRcjD9Jan1wtKkaCFWLWskxJrR5V` | ## Merkle proof @@ -227,10 +285,37 @@ The process of marking compressed accounts as spent to prevent double-spending. When compressed accounts are used as inputs in transactions, their previous states are invalidated by inserting their hashes into nullifier queues. Forester nodes process these queues to permanently update the corresponding Merkle tree leaves, ensuring each compressed account state can only be used once. +## Nullifier + +A nullifier is a unique identifier used to prevent an event from being executed more than once. It acts as a one-way, irreversible proof that a specific resource (such as a payment, note, token, or vote) has already been consumed. To implement nullifiers we need a data structure that ensures every nullifier is only created once and never deleted. On Solana a straight forward way to implement nullifiers is to create a PDA account with the nullifier as seed. + +The documentation provides two implementations with rent-free PDA accounts: + +**Nullifier PDA** — For use cases such as sending payments, where you want to prevent your on-chain instruction from being executed more than once. The nullifier program utility creates a rent-free PDA derived from id. If the id has been used before, the PDA already exists, causing the instruction to fail. + +| | | +|---|---| +| **Program ID** | `NFLx5WGPrTHHvdRNsidcrNcLxRruMC92E4yv7zhZBoT` | +| **Source code** | [github.com/Lightprotocol/nullifier-program](https://github.com/Lightprotocol/nullifier-program/) | +| **Rust SDK** | [light-nullifier-program](https://crates.io/crates/light-nullifier-program) | +| **TypeScript SDK** | [@lightprotocol/nullifier-program](https://www.npmjs.com/package/@lightprotocol/nullifier-program) | + +> [Docs](/compressed-pdas/guides/how-to-create-nullifier-pdas) | [Skill](https://github.com/Lightprotocol/skills/tree/main/skills/payments-and-wallets) | [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/actions/create_nullifier.rs) + +**ZK nullifier** — For ZK or privacy-preserving programs on Solana to prevent double-spending. Can be integrated with minimal code changes. + +> [Docs](/zk/overview) | [Skill](https://github.com/Lightprotocol/skills/tree/main/skills/zk-nullifier) | [Example](https://github.com/Lightprotocol/program-examples/tree/main/zk/zk-nullifier) + ## Nullifier queue A queue where compressed accounts hashes used as input for transactions are temporarily stored to prevent double spending. A Forester node empties the queue by inserting queue elements into a state Merkle tree. +## Output queue + +A queue in V2 state trees that buffers compressed account state changes before Forester nodes incorporate them into the state tree. Replaces the nullifier queue used in V1 state trees. + +Addresses are listed under the state tree entry. + ## Parallelism The ability of the SVM to execute multiple transactions simultaneously, as long as they modify different regular and/or compressed accounts. @@ -267,6 +352,10 @@ They are off the Ed25519 curve, meaning they have no private key. The PDA itself The on-chain process of validating zero-knowledge proofs to confirm the correctness of compressed account state transitions. +## Registered Program PDA + +A PDA that grants a program access control to the Account Compression Program. Required as an account in transactions that modify compressed state. + ## Rent A fee paid in SOL for the creation of [Accounts](https://solana.com/docs/references/terminology#account) to store data on the blockchain, tied to account size. When accounts do not have enough balance to pay rent, they may be Garbage Collected. @@ -324,6 +413,8 @@ A [library of programs](https://spl.solana.com/) on Solana such as spl-token tha A PDA owned by the Light Token Program's CPI authority that holds SPL tokens corresponding to compressed tokens and Light Token balances in circulation. Each SPL interface PDA is associated with a specific mint. +> **Address**: `GXtd2izAiMJPwMEjfgTRH3d7k9mjn4Jq3JrWFv9gySYy` + ## State A snapshot representing the current status of all accounts and programs on Solana. @@ -366,6 +457,15 @@ Two state tree versions with different proof mechanisms are currently supported: - **V1 state trees**: Always require the full 128-byte validity proof. With a depth of 26, a single V1 state tree stores approximately 67 million compressed accounts. - **V2 batched state trees**: Support `prove_by_index` optimization that verifies account existence with one byte instead of 128 bytes, optimizing compute unit consumption by up to 70%. +| Instance | State Tree | Output Queue | CPI Context | +|:---------|:-----------|:-------------|:------------| +| V2 #1 | `bmt1LryLZUMmF7ZtqESaw7wifBXLfXHQYoE4GAmrahU` | `oq1na8gojfdUhsfCpyjNt6h4JaDWtHf1yQj4koBWfto` | `cpi15BoVPKgEPw5o8wc2T816GE7b378nMXnhH3Xbq4y` | +| V2 #2 | `bmt2UxoBxB9xWev4BkLvkGdapsz6sZGkzViPNph7VFi` | `oq2UkeMsJLfXt2QHzim242SUi3nvjJs8Pn7Eac9H9vg` | `cpi2yGapXUR3As5SjnHBAVvmApNiLsbeZpF3euWnW6B` | +| V2 #3 | `bmt3ccLd4bqSVZVeCJnH1F6C8jNygAhaDfxDwePyyGb` | `oq3AxjekBWgo64gpauB6QtuZNesuv19xrhaC1ZM1THQ` | `cpi3mbwMpSX8FAGMZVP85AwxqCaQMfEk9Em1v8QK9Rf` | +| V2 #4 | `bmt4d3p1a4YQgk9PeZv5s4DBUmbF5NxqYpk9HGjQsd8` | `oq4ypwvVGzCUMoiKKHWh4S1SgZJ9vCvKpcz6RT6A8dq` | `cpi4yyPDc4bCgHAnsenunGA8Y77j3XEDyjgfyCKgcoc` | +| V2 #5 | `bmt5yU97jC88YXTuSukYHa8Z5Bi2ZDUtmzfkDTA2mG2` | `oq5oh5ZR3yGomuQgFduNDzjtGvVWfDRGLuDVjv9a96P` | `cpi5ZTjdgYpZ1Xr7B1cMLLUE81oTtJbNNAyKary2nV6` | +| V1 | `smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho` | `nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X` | `cpi2cdhkH5roePvcudTgUL8ppEBfTay1desGh8G8QxK` | + ## Token account A token account is an account type in Solana's Token Programs that stores information about an individual's ownership of a specific token (mint). Each token account is associated with a single mint and tracks details like the token balance and owner. @@ -392,11 +492,11 @@ The _validity proof_ is - verified against the respective on chain fingerprint to ensure the provided data was previously emitted - provided and generated by indexers that support the [ZK Compression RPC API](https://www.zkcompression.com/developers/json-rpc-methods) which extend Solana's [JSON RPC API](https://solana.com/docs/rpc) to interact with compressed accounts. -## Wrap and unwrap +## Wrap and Unwrap SPL, Token-2022, and Light Token Accounts **Wrap** moves tokens from an SPL or Token 2022 account into a Light Token associated token account. **Unwrap** moves tokens from a Light Token associated token account back to an SPL or Token 2022 account. Use wrap/unwrap to interact with applications that only support SPL or Token 2022. -[Docs](/light-token/cookbook/wrap-unwrap) | [Source Code](https://github.com/Lightprotocol/light-protocol/blob/0c4e2417b2df2d564721b89e18d1aad3665120e7/js/compressed-token/src/v3/actions/wrap.ts) +> [Docs](/light-token/cookbook/wrap-unwrap) | [Source Code](https://github.com/Lightprotocol/light-protocol/blob/0c4e2417b2df2d564721b89e18d1aad3665120e7/js/compressed-token/src/v3/actions/wrap.ts) ## Zero-knowledge proof (ZKP) @@ -415,6 +515,9 @@ A generalized compression framework to compress and verify arbitrary data with z - solve Solana's state growth problem, and - build a foundation for native zk compute. +The Light Token program uses ZK Compression under the hood for inactive token accounts (cold state). +A Light Token account, Light Token mint, or Light-PDA that has been compressed after extended inactivity. The account’s state is cryptographically preserved on the Solana ledger as a compressed account. On-chain lookups return is_initialized: false. Clients call create_load_instructions to reinstate the account. + ## ZK-SNARK Zero-Knowledge Succinct Non-Interactive Arguments of Knowledge. A cryptographic proof system where a prover demonstrates knowledge of information without revealing the information itself. From a99e75803751ad83e1c82f14b03343936b4de6d9 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Fri, 13 Feb 2026 17:22:34 +0000 Subject: [PATCH 14/27] fix compressed token --- compressed-tokens/overview.mdx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/compressed-tokens/overview.mdx b/compressed-tokens/overview.mdx index 9f97ba98..7a4dcc6a 100644 --- a/compressed-tokens/overview.mdx +++ b/compressed-tokens/overview.mdx @@ -1,5 +1,5 @@ --- -title: Overview +title: "Compressed Tokens" description: "Compressed tokens are the most efficient way to distribute SPL tokens (eg rewards, airdrops). For other token purposes use Light Token." keywords: ["compressed tokens on solana", "scalable token distribution on solana", "infrastructure for token distribution", "airdrop infrastructure on solana", "launchpad infrastructure on solana"] --- @@ -55,10 +55,17 @@ For production use today, use Compressed Tokens, which are on Solana Mainnet. /> -## RPC Methods +## RPC methods -The Photon API provides ZK Compression methods that extend default Solana JSON RPC API. -Detailed documentation can be found [here](https://www.helius.dev/docs/api-reference/zk-compression). +The Photon API provides ZK Compression methods that extend the default Solana JSON RPC API. + + ## Guides From 2a5e3e1300ea5da76da4eaec23840171fc819b52 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Fri, 13 Feb 2026 17:34:46 +0000 Subject: [PATCH 15/27] fix broken links --- .../how-to-create-compressed-accounts.mdx | 4 +--- compressed-tokens/for-privy.mdx | 2 +- home.mdx | 4 ++-- ...compressed-tokens-advanced-guides-table.mdx | 3 --- .../compressed-tokens-guides-table.mdx | 18 +++++++++--------- .../setup/compressed-tokens-mint-prereq.mdx | 2 +- 6 files changed, 14 insertions(+), 19 deletions(-) diff --git a/compressed-pdas/guides/how-to-create-compressed-accounts.mdx b/compressed-pdas/guides/how-to-create-compressed-accounts.mdx index 32533423..987f7dea 100644 --- a/compressed-pdas/guides/how-to-create-compressed-accounts.mdx +++ b/compressed-pdas/guides/how-to-create-compressed-accounts.mdx @@ -14,9 +14,7 @@ Compressed accounts and addresses are created via CPI to the Light System Progra * Compressed and regular Solana accounts share the same functionality and are fully composable. * A compressed account has two identifiers: the account hash and its address (optional). In comparison, regular Solana accounts are identified by their address. * The account hash is not persistent and changes with every write to the account. -* For Solana PDA like behavior your compressed account needs an address as persistent identifier.\ - Fungible state like [compressed token accounts](/compressed-tokens/guides/create-compressed-token-accounts) do not need addresses. - +* For Solana PDA like behavior your compressed account needs an address as persistent identifier. Find [full code examples at the end](/compressed-pdas/guides/how-to-create-compressed-accounts#full-code-example) for Anchor and native Rust. diff --git a/compressed-tokens/for-privy.mdx b/compressed-tokens/for-privy.mdx index c9ba48bc..0d422410 100644 --- a/compressed-tokens/for-privy.mdx +++ b/compressed-tokens/for-privy.mdx @@ -96,7 +96,7 @@ const rpc = createRpc(RPC_ENDPOINT); Before we call compress or decompresss, we need: -* An SPL mint with a interface PDA for compression. This PDA can be created for new SPL mints via [`createMint()`](/compressed-tokens/guides/create-mint-with-token-pool) or added to existing SPL mints via [`createSplInterface()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts). +* An SPL mint with a interface PDA for compression. This PDA can be created for new SPL mints via [`createMint()`](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) or added to existing SPL mints via [`createSplInterface()`](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook). * For `compress()` SPL tokens in an Associated Token Account, or * For `decompress()` compressed token accounts with sufficient balance. diff --git a/home.mdx b/home.mdx index 5d8b9d22..8c220eb0 100644 --- a/home.mdx +++ b/home.mdx @@ -214,9 +214,9 @@ codex mcp add deepwiki -- npx -y mcp-remote@latest https://mcp.deepwiki.com/mcp Learn core concepts of the Light token program and ZK Compression Core. - + Syntax reference for #[light_account] constraints for PDA, mint, token, and associated token accounts. - + RPC endpoints and addresses for programs, Merkle trees, and other accounts. diff --git a/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx b/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx index 13e4fd21..48166ba4 100644 --- a/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx +++ b/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx @@ -1,7 +1,4 @@ | Guide | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | | [Create an Airdrop without Claim](/compressed-tokens/airdrop) | ZK Compression is the most efficient way to distribute SPL tokens. Distribute via Webapp or customize with claim. | -| [Combine Instructions in One Transaction](/compressed-tokens/advanced-guides/how-to-combine-operations-in-one-transaction) | Execute multiple token instructions within a single transaction | -| [For Wallet Applications](/compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens) | Add compressed token support in your wallet application | -| [Use Token-2022 with Compression](/compressed-tokens/advanced-guides/use-token-2022-with-compression) | Create compressed Token-2022 mints with metadata and other extensions | | [Privy Guide](/compressed-tokens/for-privy) | Integrate compressed tokens with Privy embedded wallets for rent-free token accounts | diff --git a/snippets/overview-tables/compressed-tokens-guides-table.mdx b/snippets/overview-tables/compressed-tokens-guides-table.mdx index 4e5d2458..b6b4e758 100644 --- a/snippets/overview-tables/compressed-tokens-guides-table.mdx +++ b/snippets/overview-tables/compressed-tokens-guides-table.mdx @@ -1,11 +1,11 @@ | Guide | Description | | :---------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------- | -| [Create Compressed Token Accounts](/compressed-tokens/guides/create-compressed-token-accounts) | Create compressed and learn difference to regular token accounts | -| [Mint Compressed Tokens](/compressed-tokens/guides/mint-compressed-tokens) | Create new compressed tokens to existing mint | -| [Transfer Compressed Tokens](/compressed-tokens/guides/transfer-compressed-tokens) | Move compressed tokens between compressed accounts | -| [Decompress and Compress Tokens](/compressed-tokens/guides/compress-decompress) | Convert SPL tokens between regular and compressed format | -| [Compress Complete SPL Token Accounts](/compressed-tokens/guides/compress-spl-token-account) | Compress complete SPL token accounts and reclaim rent afterwards | -| [Create a mint with SPL interface](/compressed-tokens/guides/create-mint-with-token-pool) | Create new SPL mint with SPL Interface PDA for compression | -| [Create SPL interface for existing mints](/compressed-tokens/guides/add-token-pools-to-mint-accounts) | Create SPL Interface PDA (omnibus account) for existing SPL mints | -| [Merge Compressed Accounts](/compressed-tokens/guides/merge-compressed-token-accounts) | Consolidate multiple compressed accounts of the same mint into one | -| [Approve and Revoke Delegate Authority](/compressed-tokens/guides/delegate) | Approve or revoke delegates for compressed token accounts | +| [Create Compressed Token Accounts](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) | Create compressed and learn difference to regular token accounts | +| [Mint Compressed Tokens](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) | Create new compressed tokens to existing mint | +| [Transfer Compressed Tokens](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) | Move compressed tokens between compressed accounts | +| [Decompress and Compress Tokens](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) | Convert SPL tokens between regular and compressed format | +| [Compress Complete SPL Token Accounts](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) | Compress complete SPL token accounts and reclaim rent afterwards | +| [Create a Mint with Interface PDA](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) | Create new SPL mint with SPL Interface PDA for compression | +| [Create SPL Interface for Existing Mints](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) | Create SPL Interface PDA for existing SPL mints | +| [Merge Compressed Accounts](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) | Consolidate multiple compressed accounts of the same mint into one | +| [Approve and Revoke Delegate Authority](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) | Approve or revoke delegates for compressed token accounts | \ No newline at end of file diff --git a/snippets/setup/compressed-tokens-mint-prereq.mdx b/snippets/setup/compressed-tokens-mint-prereq.mdx index 6d55f472..f902e9a8 100644 --- a/snippets/setup/compressed-tokens-mint-prereq.mdx +++ b/snippets/setup/compressed-tokens-mint-prereq.mdx @@ -1,5 +1,5 @@ The SPL mint must have an SPL Interface PDA for compression.
The script creates it for you. -For development, create a new mint with SPL interface via [`createMint()`](/compressed-tokens/guides/create-mint-with-token-pool) or add an SPL interface to an existing mint via [`createSplInterface()`](/compressed-tokens/guides/add-token-pools-to-mint-accounts). +For development, create a new mint with SPL interface via [`createMint()`](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook) or add an SPL interface to an existing mint via [`createSplInterface()`](https://github.com/Lightprotocol/examples-zk-compression/tree/main/compressed-token-cookbook).
From f450402338eb3338863f4403a601a61f7c1ca48b Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Fri, 13 Feb 2026 18:22:01 +0000 Subject: [PATCH 16/27] bump intro light token page --- ai-tools/guide.mdx | 5 +-- light-token/welcome.mdx | 77 ++++++++++++++++++++++++++++++++--------- 2 files changed, 64 insertions(+), 18 deletions(-) diff --git a/ai-tools/guide.mdx b/ai-tools/guide.mdx index 9416876f..20a75230 100644 --- a/ai-tools/guide.mdx +++ b/ai-tools/guide.mdx @@ -21,8 +21,7 @@ with Light Protocol and ZK Compression. If you're building with agents, start he npx skills add https://zkcompression.com ``` -Dedicated agent skills can be found and installed below: - +Install or view dedicated agent skills: | Use case | Skill | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | @@ -35,6 +34,8 @@ Dedicated agent skills can be found and installed below: | Testing programs and clients on localnet, devnet, mainnet | [testing](https://github.com/Lightprotocol/skills/tree/main/skills/testing) | | Help with Debugging and Questions via DeepWiki MCP | [ask-mcp](https://github.com/Lightprotocol/skills/tree/main/skills/ask-mcp) | +> View all skills here: https://github.com/Lightprotocol/skills. + All skills are included and are auto-discovered based on context. Ask about light-token, defi, payments, or program migration and the agent uses the relevant skill automatically. diff --git a/light-token/welcome.mdx b/light-token/welcome.mdx index 277bcdff..8863edfb 100644 --- a/light-token/welcome.mdx +++ b/light-token/welcome.mdx @@ -5,18 +5,7 @@ description: Light token is a high-performance token standard that reduces the c keywords: ["rent free tokens on solana", "rent free solana accounts", "spl token alternative for developers", "token 2022 alternative for solana", "infrastructure for stablecoin payments on solana", "scalable solana infrastructure", "token infrastructure for fintechs", "scalable infrastructure for solana apps"] --- -import GuidesTable from "/snippets/overview-tables/compressed-tokens-guides-table.mdx"; -import AdvancedGuidesTable from "/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx"; -import SetupEnvironment from "/snippets/setup/setup-environment-tabs.mdx"; -import InstallDependencies from "/snippets/setup/install-dependencies-codegroup.mdx"; -import { LightTokenVsSplCalculator } from "/snippets/jsx/light-token-vs-spl-calculator.jsx"; -import { CompressibleRentCalculator } from "/snippets/jsx/compressible-rent-calculator.jsx"; -import { RentLifecycleVisualizer } from "/snippets/jsx/rent-lifecycle-visualizer.jsx"; -import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx"; -import CompressibleDefaultRentConfig from "/snippets/compressible-default-rent-config.mdx"; -import IntegrateLightTokenGuidesTable from "/snippets/overview-tables/integrate-light-token-guides-table.mdx"; import CookbookGuidesTable from "/snippets/overview-tables/cookbook-guides-table.mdx"; -import ExamplesGuidesTable from "/snippets/overview-tables/examples-guides-table.mdx"; import WelcomePageInstall from "/snippets/setup/welcome-page-install.mdx"; import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; @@ -80,16 +69,59 @@ import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; - Build rent-free AMMs and DeFi programs with minimal code changes. + Build rent-free AMMs and DeFi programs. - Add support for rent-free AMMs to your aggregator or router. + Add support for rent-free AMMs to your aggregator. + + + High-performance DeFi programs with Pinocchio. + + + +## Payments + + + + Guide to integrate light-token APIs with comparison to SPL. + + + Prevent onchain instructions from being executed more than once. + + + +## Wallets + + + + Guide for Wallet Applications to let users display and swap light-tokens. + + + Add rent-free tokens to Privy embedded wallets. -## Integration Toolkits +## Data Streaming - + + + Stream mint events from the network in real-time. + + + Stream token events from the network in real-time. + + + +## PDA Accounts + + + + Solana PDAs with sponsored rent-exemption that can be implemented with minimal code changes. + + + Syntax reference for #[light_account] constraints for PDA, mint, token, and associated token accounts. + + ## Cookbook @@ -97,7 +129,20 @@ import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; ## Examples - +### Client + +| | | +| :--- | :--- | +| [**TypeScript**](/light-token/examples/client#typescript) | Actions and instructions for all token operations | +| [**Rust**](/light-token/examples/client#rust) | Actions and instructions for all token operations | + +### Program + +| | | +| :--- | :--- | +| [**Examples**](/light-token/examples/program#examples) | AMM reference, CPI create-and-transfer, Pinocchio swap | +| [**Macros**](/light-token/examples/program#macros) | Counter PDA, ATA, mint, and token account creation | +| [**Instructions**](/light-token/examples/program#instructions) | All CPI instructions: approve, burn, close, freeze, mint-to, transfer, and more | ## SDK Reference From 2c9236f53b96f3154f983026ae8738b1188efbb3 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Fri, 13 Feb 2026 18:25:44 +0000 Subject: [PATCH 17/27] before rebase --- light-token/pda-overview.mdx | 8 +++++--- light-token/welcome.mdx | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/light-token/pda-overview.mdx b/light-token/pda-overview.mdx index 3f845884..c00e0044 100644 --- a/light-token/pda-overview.mdx +++ b/light-token/pda-overview.mdx @@ -10,6 +10,8 @@ import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx Light-PDAs are Solana PDAs with sponsored rent-exemption created using Anchor `#[account(init)]` with `#[light_account(init)]`. Can be implemented with minimal code changes to your existing Solana program and leaves program logic mostly untouched. +> Use like any other PDA, e.g. in your DeFi program. + | | Regular PDA | Light-PDA | |------------------|----------------------|-----------------| | 100-byte account | ~1,600,000 lamports | ~11,500 lamports | @@ -21,24 +23,24 @@ Can be implemented with minimal code changes to your existing Solana program and - Standard Anchor account type (`Account<'info, T>`) - Reads, updates, and closes are unchanged - Inactive accounts auto-compress; clients load them back when needed -- Use like any other PDA, e.g. in your DeFi program. --- -## Compressed PDA +## Advanced: Compressed PDA Compressed PDAs are compressed accounts with an address. Programs invoke the Light System program to create and update compressed accounts, instead of the System program. Fully compatible with existing Solana programs, but requires custom logic. +> Use for app and user state, or other accounts that are infrequently accessed. + | | Regular PDA | Compressed PDA | |------------------|----------------------|-----------------| | 100-byte account | ~1,600,000 lamports | 15,000 lamports | - Derived using a program address and seed, like regular PDAs - Compressed state requires a validity proof for every read and write (fetched by client from RPC that supports ZK Compression, such as Helius and Triton) -- Use for app and user state, or other accounts that are infrequently accessed \ No newline at end of file diff --git a/light-token/welcome.mdx b/light-token/welcome.mdx index 8863edfb..d4a83c15 100644 --- a/light-token/welcome.mdx +++ b/light-token/welcome.mdx @@ -116,7 +116,7 @@ import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; - Solana PDAs with sponsored rent-exemption that can be implemented with minimal code changes. + Solana PDAs with sponsored rent-exemption that can be implemented with minimal code changes. Use like any other PDA, e.g. in your DeFi program. Syntax reference for #[light_account] constraints for PDA, mint, token, and associated token accounts. From 88532337e867b71665dbeb7c3a030e9aca0d9844 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Sun, 15 Feb 2026 21:54:10 +0000 Subject: [PATCH 18/27] add skills --- ai-tools/guide.mdx | 27 +- api-reference/json-rpc-methods/overview.mdx | 20 +- ask.skill | Bin 0 -> 636 bytes client-library/client-guide.mdx | 2 +- docs.json | 387 ++++++++---------- home.mdx | 13 +- learn/core-concepts/considerations.mdx | 2 +- learn/core-concepts/transaction-lifecycle.mdx | 2 +- light-token/cookbook/approve-revoke.mdx | 3 + light-token/cookbook/burn.mdx | 3 + light-token/cookbook/close-token-account.mdx | 3 + light-token/cookbook/create-ata.mdx | 3 + light-token/cookbook/create-mint.mdx | 11 +- light-token/cookbook/create-token-account.mdx | 5 +- light-token/cookbook/freeze-thaw.mdx | 3 + light-token/cookbook/load-ata.mdx | 3 + light-token/cookbook/mint-to.mdx | 3 + light-token/cookbook/transfer-checked.mdx | 3 + light-token/cookbook/transfer-interface.mdx | 3 + light-token/cookbook/wrap-unwrap.mdx | 3 + light-token/defi/programs-pinocchio.mdx | 5 + light-token/defi/programs.mdx | 5 + light-token/defi/routers.mdx | 5 + light-token/examples/client.mdx | 3 + light-token/examples/program.mdx | 3 + light-token/quickstart.mdx | 3 + light-token/toolkits/for-payments.mdx | 79 +--- light-token/toolkits/for-privy.mdx | 190 +++++++++ light-token/toolkits/for-streaming-mints.mdx | 3 + light-token/toolkits/for-streaming-pdas.mdx | 4 + light-token/toolkits/for-streaming-tokens.mdx | 3 + light-token/toolkits/for-wallets.mdx | 3 + light-token/welcome.mdx | 19 +- .../compressed-pdas}/guides.mdx | 2 +- .../how-to-burn-compressed-accounts.mdx | 6 +- .../how-to-close-compressed-accounts.mdx | 8 +- .../how-to-create-compressed-accounts.mdx | 6 +- .../guides/how-to-create-nullifier-pdas.mdx | 0 ...ow-to-reinitialize-compressed-accounts.mdx | 6 +- .../how-to-update-compressed-accounts.mdx | 6 +- .../compressed-pdas}/overview.mdx | 0 .../compressed-pdas}/program-examples.mdx | 2 +- .../solana-attestation-service.mdx | 0 .../light-pda/overview.mdx | 15 +- .../pda-overview.mdx => pda/overview.mdx | 15 +- references/migration-v1-to-v2.mdx | 2 +- references/terminology.mdx | 6 +- resources/addresses-and-urls.mdx | 2 +- resources/cli-installation.mdx | 2 +- resources/sdks/program-development.mdx | 4 +- .../code-snippets/privy/balances/nodejs.mdx | 150 +++++-- .../code-snippets/privy/balances/react.mdx | 175 +------- .../code-snippets/privy/compress/nodejs.mdx | 89 ---- .../code-snippets/privy/compress/react.mdx | 106 ----- .../code-snippets/privy/decompress/nodejs.mdx | 81 ---- .../code-snippets/privy/decompress/react.mdx | 124 ------ .../privy/transaction-history/nodejs.mdx | 42 +- .../privy/transaction-history/react.mdx | 97 +---- .../code-snippets/privy/transfer/nodejs.mdx | 97 ++--- .../code-snippets/privy/transfer/react.mdx | 106 +---- .../code-snippets/privy/unwrap/nodejs.mdx | 68 +++ snippets/code-snippets/privy/unwrap/react.mdx | 1 + snippets/code-snippets/privy/wrap/nodejs.mdx | 86 ++++ snippets/code-snippets/privy/wrap/react.mdx | 1 + .../compressed-pdas-guides-table.mdx | 12 +- ...ompressed-tokens-advanced-guides-table.mdx | 2 +- snippets/overview-tables/sdk-reference.mdx | 10 + snippets/setup/agent-skill-defi-program.mdx | 9 + snippets/setup/agent-skill-defi-router.mdx | 9 + snippets/setup/agent-skill-generic.mdx | 11 + snippets/setup/agent-skill-payments.mdx | 9 + snippets/setup/agent-skill-streaming.mdx | 9 + snippets/setup/install-agent-skills.mdx | 27 ++ snippets/setup/register-spl-mint.mdx | 68 +++ use-agent.skill | Bin 0 -> 940 bytes zk/overview.mdx | 2 +- 76 files changed, 994 insertions(+), 1303 deletions(-) create mode 100644 ask.skill create mode 100644 light-token/toolkits/for-privy.mdx rename {compressed-pdas => pda/compressed-pdas}/guides.mdx (96%) rename {compressed-pdas => pda/compressed-pdas}/guides/how-to-burn-compressed-accounts.mdx (96%) rename {compressed-pdas => pda/compressed-pdas}/guides/how-to-close-compressed-accounts.mdx (95%) rename {compressed-pdas => pda/compressed-pdas}/guides/how-to-create-compressed-accounts.mdx (97%) rename {compressed-pdas => pda/compressed-pdas}/guides/how-to-create-nullifier-pdas.mdx (100%) rename {compressed-pdas => pda/compressed-pdas}/guides/how-to-reinitialize-compressed-accounts.mdx (96%) rename {compressed-pdas => pda/compressed-pdas}/guides/how-to-update-compressed-accounts.mdx (96%) rename {compressed-pdas => pda/compressed-pdas}/overview.mdx (100%) rename {compressed-pdas => pda/compressed-pdas}/program-examples.mdx (99%) rename {compressed-pdas => pda/compressed-pdas}/solana-attestation-service.mdx (100%) rename light-token/light-pda.mdx => pda/light-pda/overview.mdx (94%) rename light-token/pda-overview.mdx => pda/overview.mdx (64%) delete mode 100644 snippets/code-snippets/privy/compress/nodejs.mdx delete mode 100644 snippets/code-snippets/privy/compress/react.mdx delete mode 100644 snippets/code-snippets/privy/decompress/nodejs.mdx delete mode 100644 snippets/code-snippets/privy/decompress/react.mdx create mode 100644 snippets/code-snippets/privy/unwrap/nodejs.mdx create mode 100644 snippets/code-snippets/privy/unwrap/react.mdx create mode 100644 snippets/code-snippets/privy/wrap/nodejs.mdx create mode 100644 snippets/code-snippets/privy/wrap/react.mdx create mode 100644 snippets/setup/agent-skill-defi-program.mdx create mode 100644 snippets/setup/agent-skill-defi-router.mdx create mode 100644 snippets/setup/agent-skill-generic.mdx create mode 100644 snippets/setup/agent-skill-payments.mdx create mode 100644 snippets/setup/agent-skill-streaming.mdx create mode 100644 snippets/setup/install-agent-skills.mdx create mode 100644 snippets/setup/register-spl-mint.mdx create mode 100644 use-agent.skill diff --git a/ai-tools/guide.mdx b/ai-tools/guide.mdx index 20a75230..06728392 100644 --- a/ai-tools/guide.mdx +++ b/ai-tools/guide.mdx @@ -2,6 +2,7 @@ title: "AI Tools Guide" description: "Guidance to AI tools when working with ZK Compression. Includes Agent Skill, MCP server, DeepWiki, and AI Search guides." --- +import InstallAgentSkills from "/snippets/setup/install-agent-skills.mdx"; # For Docs @@ -17,10 +18,6 @@ so agents can navigate to answers quickly. View or install [`/skill.md`](https://zkcompression.com/skill.md), a structured capability file that tells agents what they can do with Light Protocol and ZK Compression. If you're building with agents, start here. -```bash -npx skills add https://zkcompression.com -``` - Install or view dedicated agent skills: | Use case | Skill | @@ -38,27 +35,7 @@ Install or view dedicated agent skills: All skills are included and are auto-discovered based on context. Ask about light-token, defi, payments, or program migration and the agent uses the relevant skill automatically. - - -Add the marketplace and install: - -``` -/plugin marketplace add Lightprotocol/skills -/plugin install solana-rent-free-dev -``` - - -1. Open Settings (**Cmd+Shift+J** / **Ctrl+Shift+J**) -2. Navigate to **Rules & Commands** → **Project Rules** → **Add Rule** → **Remote Rule (GitHub)** -3. Enter: `https://github.com/Lightprotocol/skills.git` - - - -``` -npx skills add Lightprotocol/skills -``` - - + ## MCP diff --git a/api-reference/json-rpc-methods/overview.mdx b/api-reference/json-rpc-methods/overview.mdx index 9043baf4..36dd8570 100644 --- a/api-reference/json-rpc-methods/overview.mdx +++ b/api-reference/json-rpc-methods/overview.mdx @@ -14,18 +14,14 @@ custom indexer, or working with [legacy compressed tokens](/compressed-tokens/overview). -The Light Token SDK exposes interface methods that check both hot (on-chain) and cold (compressed) state: - -| Light SDK interface method | Solana RPC | Photon RPC | -| :-------------------------------- | :---------------------- | :-------------------------------- | -| `getAccountInfoInterface` | getAccountInfo | getCompressedAccount | -| `getBalanceInterface` | getBalance | getCompressedBalanceByOwner | -| `getAtaInterface` | getAccountInfo | getCompressedTokenAccountsByOwner | -| `getTokenAccountBalanceInterface` | getTokenAccountBalance | getCompressedTokenBalancesByOwner | -| `getSignaturesForAddressInterface`| getSignaturesForAddress | getCompressionSignaturesForAddress| -| `getSignaturesForOwnerInterface` | getSignaturesForAddress | getCompressionSignaturesForOwner | - -Each interface method executes both calls in parallel and merges the results. +| Solana RPC | Photon RPC | +| :---------------------- | :-------------------------------- | +| getAccountInfo | getCompressedAccount | +| getBalance | getCompressedBalanceByOwner | +| getAccountInfo | getCompressedTokenAccountsByOwner | +| getTokenAccountBalance | getCompressedTokenBalancesByOwner | +| getSignaturesForAddress | getCompressionSignaturesForAddress| +| getSignaturesForAddress | getCompressionSignaturesForOwner | diff --git a/ask.skill b/ask.skill new file mode 100644 index 0000000000000000000000000000000000000000..749b822781836a893f45604974a77f589c093f36 GIT binary patch literal 636 zcmWIWW@Zs#U|`^2c)i*`COp;UArlh=!whBy1|FbjVsW;9u(zj=k6vy{>g4GBD+U6s z_y20U#mbpG#?1Q_w!q0_Lu=V;F2yCgKB`Eree79#Gxg`!Gb-NGb^Rwk{`g}~e&6a< zMhE#S_{?&94qtJRGA^`e_g755BlJ$;JBMmw%b5$2k**y-A~YT~D5~EGe77@2;!T?q zyKla8`^vW4EgN1N9+=0?;Lo<2q9uf4$U1$RgU#gG$8{*W3HfoNBSvb*Eg>**9lyOXYQ`Xk5y# zRW diff --git a/docs.json b/docs.json index e15a5e8d..4371769e 100644 --- a/docs.json +++ b/docs.json @@ -1,6 +1,6 @@ { "$schema": "https://mintlify.com/docs.json", - "theme": "aspen", + "theme": "maple", "name": "Light Protocol", "colors": { "primary": "#0066FF", @@ -20,225 +20,144 @@ } }, "navigation": { - "tabs": [ + "anchors": [ { - "tab": "Home", - "groups": [ - { - "group": "Overview", - "pages": [ - "home" - ] - } - ] - }, - { - "tab": "Light Token Program", + "anchor": "Documentation", + "icon": "book", "groups": [ { "group": "Get Started", "pages": [ - "light-token/welcome", - "light-token/quickstart", - "light-token/faq" - ] - }, - { - "group": "DeFi", - "pages": [ - "light-token/defi/routers", - "light-token/defi/programs", - "light-token/defi/programs-pinocchio" - ] - }, - { - "group": "Data Streaming", - "pages": [ - "light-token/toolkits/for-streaming-tokens", - "light-token/toolkits/for-streaming-mints" - ] - }, - { - "group": "Toolkits", - "pages": [ - "light-token/toolkits/overview", - "light-token/toolkits/for-payments", - "light-token/toolkits/for-wallets" - ] - }, - { - "group": "Cookbook", - "pages": [ - "light-token/cookbook/overview", + "home", { - "group": "Examples", - "expanded": true, + "group": "Light Token", "pages": [ - "light-token/examples/client", - "light-token/examples/program" + "light-token/welcome", + "light-token/faq", + "light-token/quickstart", + { + "group": "Cookbook", + "pages": [ + "light-token/cookbook/create-mint", + "light-token/cookbook/create-ata", + "light-token/cookbook/create-token-account", + "light-token/cookbook/mint-to", + "light-token/cookbook/transfer-interface", + "light-token/cookbook/transfer-checked", + "light-token/cookbook/approve-revoke", + "light-token/cookbook/freeze-thaw", + "light-token/cookbook/wrap-unwrap", + "light-token/cookbook/load-ata", + "light-token/cookbook/close-token-account", + "light-token/cookbook/burn" + ] + }, + { + "group": "Examples", + "expanded": true, + "pages": [ + "light-token/examples/client", + "light-token/examples/program" + ] + } ] }, { - "group": "Recipes", - "expanded": true, + "group": "PDA Accounts", "pages": [ - "light-token/cookbook/create-mint", - "light-token/cookbook/create-ata", - "light-token/cookbook/create-token-account", - "light-token/cookbook/mint-to", - "light-token/cookbook/transfer-interface", - "light-token/cookbook/transfer-checked", - "light-token/cookbook/approve-revoke", - "light-token/cookbook/freeze-thaw", - "light-token/cookbook/wrap-unwrap", - "light-token/cookbook/load-ata", - "light-token/cookbook/close-token-account", - "light-token/cookbook/burn" - + "pda/overview", + "pda/light-pda/overview", + { + "group": "Compressed PDA", + "pages": [ + "pda/compressed-pdas/overview", + "client-library/client-guide", + { + "group": "Program Guides", + "expanded": true, + "pages": [ + "pda/compressed-pdas/guides", + "pda/compressed-pdas/guides/how-to-create-compressed-accounts", + "pda/compressed-pdas/guides/how-to-update-compressed-accounts", + "pda/compressed-pdas/guides/how-to-close-compressed-accounts", + "pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts", + "pda/compressed-pdas/guides/how-to-burn-compressed-accounts" + ] + }, + "pda/compressed-pdas/program-examples", + { + "group": "Error Cheatsheet", + "pages": [ + "resources/error-cheatsheet", + "resources/error-cheatsheet/debug-0x179b-6043-proofverificationfailed" + ] + } + ] + } ] } ] }, { - "group": "Learn", + "group": "DeFi", "pages": [ - "learn/light-token-standard", - "ai-tools/guide" + "light-token/defi/routers", + "light-token/defi/programs", + "light-token/defi/programs-pinocchio" ] }, { - "group": "SDK Reference", - "pages": [ - "api-reference/libraries/light-sdk", - "api-reference/libraries/light-token", - "api-reference/libraries/light-program-test", - "api-reference/libraries/light-client", - "api-reference/libraries/stateless-js", - "api-reference/libraries/compressed-token" - ] - } - ] - }, - { - "tab": "ZK Compression", - "groups": [ - { - "group": "Get Started", + "group": "Data Streaming", "pages": [ - "welcome", - "quickstart" + "light-token/toolkits/for-streaming-mints", + "light-token/toolkits/for-streaming-tokens" ] }, { - "group": "ZK", + "group": "Stablecoin Payments", "pages": [ - "zk/overview", - "zk/examples" + "light-token/toolkits/for-payments", + "pda/compressed-pdas/guides/how-to-create-nullifier-pdas" ] }, { - "group": "Compressed PDAs", - "expanded": true, + "group": "Wallets", "pages": [ - "compressed-pdas/overview", - "client-library/client-guide", - { - "group": "Program Guides", - "pages": [ - "compressed-pdas/guides", - "compressed-pdas/guides/how-to-create-compressed-accounts", - "compressed-pdas/guides/how-to-update-compressed-accounts", - "compressed-pdas/guides/how-to-close-compressed-accounts", - "compressed-pdas/guides/how-to-reinitialize-compressed-accounts", - "compressed-pdas/guides/how-to-burn-compressed-accounts", - "compressed-pdas/guides/how-to-create-nullifier-pdas" - ] - }, - "compressed-pdas/program-examples", - "compressed-pdas/solana-attestation-service" + "light-token/toolkits/for-wallets", + "light-token/toolkits/for-privy" ] }, { - "group": "Compressed Tokens", + "group": "Other Use Cases", "pages": [ - "compressed-tokens/overview", - "compressed-tokens/for-privy", - "compressed-tokens/advanced-guides/airdrop", + "compressed-tokens/airdrop", + "pda/compressed-pdas/solana-attestation-service", { - "group": "Cookbook", + "group": "ZK", "pages": [ - "compressed-tokens/guides/create-compressed-token-accounts", - "compressed-tokens/guides/mint-compressed-tokens", - "compressed-tokens/guides/transfer-compressed-tokens", - "compressed-tokens/guides/compress-decompress", - "compressed-tokens/guides/compress-spl-token-account", - "compressed-tokens/guides/create-mint-with-token-pool", - "compressed-tokens/guides/add-token-pools-to-mint-accounts", - "compressed-tokens/guides/merge-compressed-token-accounts", - "compressed-tokens/guides/delegate" - ] - }, - { - "group": "Implementation Guides", - "pages": [ - { - "group": "Integration", - "expanded": true, - "pages": [ - "compressed-tokens/advanced-guides/how-to-combine-operations-in-one-transaction", - "compressed-tokens/advanced-guides/add-wallet-support-for-compressed-tokens", - "compressed-tokens/advanced-guides/use-token-2022-with-compression" - ] - }, - { - "group": "Examples", - "expanded": true, - "pages": [ - "compressed-tokens/advanced-guides/example-token-distribution" - ] - } + "zk/overview", + "zk/examples" ] } ] }, { - "group": "JSON RPC Methods", + "group": "Resources", "pages": [ - "api-reference/json-rpc-methods/overview", - { - "group": "Methods", - "pages": [ - "api-reference/json-rpc-methods/methods", - "api-reference/json-rpc-methods/getcompressedaccount", - "api-reference/json-rpc-methods/getcompressedaccountsbyowner", - "api-reference/json-rpc-methods/getcompressedbalancebyowner", - "api-reference/json-rpc-methods/getcompressedbalance", - "api-reference/json-rpc-methods/getcompressedminttokenholders", - "api-reference/json-rpc-methods/getcompressedtokenaccountbalance", - "api-reference/json-rpc-methods/getcompressedtokenaccountbydelegate", - "api-reference/json-rpc-methods/getcompressedtokenaccountsbyowner", - "api-reference/json-rpc-methods/getcompressedtokenbalancesbyowner", - "api-reference/json-rpc-methods/getcompressionsignaturesforaccount", - "api-reference/json-rpc-methods/getcompressionsignaturesforaddress", - "api-reference/json-rpc-methods/getcompressionsignaturesforowner", - "api-reference/json-rpc-methods/getcompressionsignaturesfortokenowner", - "api-reference/json-rpc-methods/getindexerhealth", - "api-reference/json-rpc-methods/getindexerslot", - "api-reference/json-rpc-methods/getlatestcompressionsignatures", - "api-reference/json-rpc-methods/getlatestnonvotingsignatures", - "api-reference/json-rpc-methods/getmultiplecompressedaccounts", - "api-reference/json-rpc-methods/getmultiplenewaddressproofs", - "api-reference/json-rpc-methods/gettransactionwithcompressioninfo", - "api-reference/json-rpc-methods/getvalidityproof" - ] - } + "api-reference/sdk", + "resources/anchor-constraints", + "resources/addresses-and-urls", + "references/migration-v1-to-v2", + "resources/cli-installation" ] }, { "group": "Learn", "pages": [ + "learn/overview", + "learn/light-token-standard", { - "group": "Core Concepts", + "group": "Core Concepts ZK Compression", "pages": [ "learn/core-concepts", "learn/core-concepts/compressed-account-model", @@ -246,50 +165,74 @@ "learn/core-concepts/transaction-lifecycle", "learn/core-concepts/considerations" ] - }, - "ai-tools/guide" - ] - }, - { - "group": "Resources", - "pages": [ - "resources/cli-installation", - { - "group": "Error Cheatsheet", - "pages": [ - "resources/error-cheatsheet", - "resources/error-cheatsheet/debug-0x179b-6043-proofverificationfailed" - ] - }, - { - "group": "SDKs", - "pages": [ - "resources/sdks/client-development", - "resources/sdks/program-development" - ] - }, - "resources/addresses-and-urls" + } ] }, { "group": "References", "pages": [ + "compressed-tokens/overview", + "references/terminology", "references/whitepaper", "references/node-operators", - "references/terminology", - "references/migration-v1-to-v2", - "support", "references/security" ] - }, + } + ] + }, + { + "anchor": "JSON RPC Methods", + "icon": "code", + "groups": [ + { + "group": "JSON RPC Methods", + "pages": [ + "api-reference/json-rpc-methods/overview", + "api-reference/json-rpc-methods/getcompressedaccount", + "api-reference/json-rpc-methods/getcompressedaccountsbyowner", + "api-reference/json-rpc-methods/getcompressedbalancebyowner", + "api-reference/json-rpc-methods/getcompressedtokenaccountsbyowner", + "api-reference/json-rpc-methods/getcompressedtokenbalancesbyowner", + "api-reference/json-rpc-methods/getvalidityproof", + "api-reference/json-rpc-methods/getcompressionsignaturesforaddress", + "api-reference/json-rpc-methods/getcompressionsignaturesforowner", + "api-reference/json-rpc-methods/gettransactionwithcompressioninfo", + "api-reference/json-rpc-methods/getindexerhealth", + "api-reference/json-rpc-methods/getindexerslot", + "api-reference/json-rpc-methods/getcompressedbalance", + "api-reference/json-rpc-methods/getcompressedminttokenholders", + "api-reference/json-rpc-methods/getcompressedtokenaccountbalance", + "api-reference/json-rpc-methods/getcompressedtokenaccountbydelegate", + "api-reference/json-rpc-methods/getcompressionsignaturesforaccount", + "api-reference/json-rpc-methods/getcompressionsignaturesfortokenowner", + "api-reference/json-rpc-methods/getlatestcompressionsignatures", + "api-reference/json-rpc-methods/getlatestnonvotingsignatures", + "api-reference/json-rpc-methods/getmultiplecompressedaccounts", + "api-reference/json-rpc-methods/getmultiplenewaddressproofs" + ] + } + ] + }, + { + "anchor": "AI Tools", + "icon": "robot", + "groups": [ + { + "group": "AI Tools", + "pages": [ + "ai-tools/guide" + ] + } + ] + }, + { + "anchor": "Support", + "icon": "headset", + "groups": [ { - "group": "SDK Reference", + "group": "Support", "pages": [ - "api-reference/libraries/stateless-js", - "api-reference/libraries/compressed-token", - "api-reference/libraries/light-client", - "api-reference/libraries/light-sdk", - "api-reference/libraries/light-program-test" + "support" ] } ] @@ -317,15 +260,9 @@ "navbar": { "links": [ { - "label": "Get Support", - "icon": "discord", - "href": "https://discord.gg/CYvjBgzRFP" - }, - { - "type": "button", "label": "GitHub", "icon": "github", - "href": "https://github.com/Lightprotocol/light-protocol" + "href": "https://github.com/Lightprotocol" } ] }, @@ -365,11 +302,27 @@ "redirects": [ { "source": "/landing", - "destination": "/welcome" + "destination": "/home" + }, + { + "source": "/welcome", + "destination": "/home" + }, + { + "source": "/learn/ai-tools-guide", + "destination": "/ai-tools/guide" + }, + { + "source": "/resources/sdks/client-development", + "destination": "/api-reference/sdk" + }, + { + "source": "/resources/sdks/program-development", + "destination": "/api-reference/sdk" }, { - "source": "https://www.zkcompression.com/learn/ai-tools-guide", - "destination": "https://www.zkcompression.com/ai-tools/guide" + "source": "/compressed-tokens/for-privy", + "destination": "/light-token/toolkits/for-privy" } ] -} \ No newline at end of file +} diff --git a/home.mdx b/home.mdx index 8c220eb0..c3a93ed8 100644 --- a/home.mdx +++ b/home.mdx @@ -1,5 +1,6 @@ --- title: "Home" +sidebarTitle: "Introduction" mode: "custom" keywords: ["solana tokens", "spl tokens", "light protocol", "helius", "zk compression on solana", "scalable solana infrastructure", "rent free accounts on solana", "create tokens on solana", "scalable infrastructure for solana apps", "privacy on solana", "shielded transactions on solana"] --- @@ -60,7 +61,7 @@ while being more CU efficient than SPL on hot paths. Guide to integrate light-token APIs with comparison to SPL. - + Prevent onchain instructions from being executed more than once. @@ -71,8 +72,8 @@ while being more CU efficient than SPL on hot paths. Guide for Wallet Applications to let users display and swap light-tokens. - - Add rent-free tokens to Privy embedded wallets. + + Add light-tokens to Privy embedded wallets.
@@ -104,11 +105,11 @@ while being more CU efficient than SPL on hot paths. ## PDA Accounts - + Solana PDAs with sponsored rent-exemption that can be implemented with minimal code changes. Use like any other PDA, e.g. in your DeFi program. - + Compressed PDAs to store user, app, or other infrequently accessed state without rent-exemption. Fully compatible with existing Solana programs, but requires custom logic. @@ -119,7 +120,7 @@ while being more CU efficient than SPL on hot paths. Distribute tokens on Solana 5000x cheaper. Merkle distributor and simple claim programs for airdrops with claim. - + Credential system for KYC verification, professional badges, and compliance credentials in minutes. diff --git a/learn/core-concepts/considerations.mdx b/learn/core-concepts/considerations.mdx index 0651fff8..4b8f2624 100644 --- a/learn/core-concepts/considerations.mdx +++ b/learn/core-concepts/considerations.mdx @@ -81,7 +81,7 @@ You're ready to take the next step and start building! title="Compressed PDAs" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/overview" + href="/pda/compressed-pdas/overview" horizontal />
\ No newline at end of file diff --git a/learn/core-concepts/transaction-lifecycle.mdx b/learn/core-concepts/transaction-lifecycle.mdx index 3b257dc7..f234959d 100644 --- a/learn/core-concepts/transaction-lifecycle.mdx +++ b/learn/core-concepts/transaction-lifecycle.mdx @@ -138,7 +138,7 @@ The Solana program executing the state transition _**Data**_** -> **_**Data'**_ - `validity proof`: 128-byte ZK proof that verifies the current account hash exists in the state tree -See this [guide to update a compressed account](/compressed-pdas/guides/how-to-update-compressed-accounts). +See this [guide to update a compressed account](/pda/compressed-pdas/guides/how-to-update-compressed-accounts). diff --git a/light-token/cookbook/approve-revoke.mdx b/light-token/cookbook/approve-revoke.mdx index ef6cad7d..efa31db0 100644 --- a/light-token/cookbook/approve-revoke.mdx +++ b/light-token/cookbook/approve-revoke.mdx @@ -28,6 +28,7 @@ import RevokeActionCode from "/snippets/code-snippets/light-token/approve-revoke import RevokeInstructionCode from "/snippets/code-snippets/light-token/approve-revoke/rust-client/revoke-instruction.mdx"; import ApproveAnchorProgramCode from "/snippets/code-snippets/light-token/approve/anchor-program/full-example.mdx"; import RevokeAnchorProgramCode from "/snippets/code-snippets/light-token/revoke/anchor-program/full-example.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 1. Approve grants a delegate permission to transfer up to a specified amount of tokens from your account. * Each token account can have only one delegate at a time. @@ -299,3 +300,5 @@ revoke_cpi.invoke_signed(&[signer_seeds])?; href="/light-token/welcome" horizontal /> + + diff --git a/light-token/cookbook/burn.mdx b/light-token/cookbook/burn.mdx index 8496e376..552073fa 100644 --- a/light-token/cookbook/burn.mdx +++ b/light-token/cookbook/burn.mdx @@ -16,6 +16,7 @@ import { import RustInstructionCode from "/snippets/code-snippets/light-token/burn/rust-client/instruction.mdx"; import BurnCheckedRustInstructionCode from "/snippets/code-snippets/light-token/burn-checked/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/burn/anchor-program/full-example.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 1. Burn permanently destroys tokens by reducing the balance in a token account. @@ -135,3 +136,5 @@ BurnCpi { href="/light-token/cookbook/freeze-thaw" horizontal /> + + diff --git a/light-token/cookbook/close-token-account.mdx b/light-token/cookbook/close-token-account.mdx index 4ef0caaa..ed0dbca0 100644 --- a/light-token/cookbook/close-token-account.mdx +++ b/light-token/cookbook/close-token-account.mdx @@ -17,6 +17,7 @@ import { } from "/snippets/code-samples/code-compare-snippets.jsx"; import RustInstructionCode from "/snippets/code-snippets/light-token/close-token-account/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/close-token-account/anchor-program/full-example.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 1. Closing a Light Token account transfers remaining lamports to a destination account and the rent sponsor can reclaim sponsored rent. 2. Light token accounts can be closed by the owner. @@ -144,3 +145,5 @@ CloseAccountCpi { href="/light-token/welcome" horizontal /> + + diff --git a/light-token/cookbook/create-ata.mdx b/light-token/cookbook/create-ata.mdx index fc52f275..56a68f34 100644 --- a/light-token/cookbook/create-ata.mdx +++ b/light-token/cookbook/create-ata.mdx @@ -27,6 +27,7 @@ import RustActionCode from "/snippets/code-snippets/light-token/create-ata/rust- import RustInstructionCode from "/snippets/code-snippets/light-token/create-ata/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/create-ata/anchor-program/full-example.mdx"; import AnchorMacroCode from "/snippets/code-snippets/light-token/create-ata/anchor-macro/full-example.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 1. Associated Light Token accounts can hold token balances of light, SPL, or Token 2022 mints. 2. Light-ATAs are on-chain accounts like SPL ATA's, but the light token program sponsors the rent-exemption cost for you. @@ -35,6 +36,8 @@ import AnchorMacroCode from "/snippets/code-snippets/light-token/create-ata/anch + + diff --git a/light-token/cookbook/create-mint.mdx b/light-token/cookbook/create-mint.mdx index 2cb1be99..7201ede4 100644 --- a/light-token/cookbook/create-mint.mdx +++ b/light-token/cookbook/create-mint.mdx @@ -40,6 +40,7 @@ import RustInstructionCode from "/snippets/code-snippets/light-token/create-mint import AnchorProgramCode from "/snippets/code-snippets/light-token/create-mint/anchor-program/full-example.mdx"; import AnchorMacroCode from "/snippets/code-snippets/light-token/create-mint/anchor-macro/full-example.mdx"; import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 1. Mint accounts uniquely represent a token on Solana and store its global metadata. 2. Light mints are on-chain accounts like SPL mints, but the light token program sponsors the rent-exemption cost for you. @@ -50,6 +51,8 @@ import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx + + @@ -153,7 +156,7 @@ Pass `TOKEN_2022_PROGRAM_ID` to create a Token-2022 mint with an interface PDA i `CreateMint` creates an on-chain mint account that can optionally include token metadata. The instruction also writes a compressed mint address to the address Merkle tree, which preserves the mint state when the on-chain account is compressed. -Compare to SPL: +Compare to SPL: The address of the mint account is stored in an address Merkle tree - , which is maintained by the protocol. + , which is maintained by the protocol. The client passes a validity proof that proves the mint address does not - exist yet. + exist yet. @@ -288,7 +291,7 @@ let params = CreateMintParams { ### System Accounts -Include system accounts such as the Light System Program +Include system accounts such as the Light System Program to verify the proof and write the mint address to the address tree. diff --git a/light-token/cookbook/create-token-account.mdx b/light-token/cookbook/create-token-account.mdx index 8620b4bb..88761d9a 100644 --- a/light-token/cookbook/create-token-account.mdx +++ b/light-token/cookbook/create-token-account.mdx @@ -22,14 +22,17 @@ import { import RustInstructionCode from "/snippets/code-snippets/light-token/create-token-account/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/create-token-account/anchor-program/full-example.mdx"; import AnchorMacroCode from "/snippets/code-snippets/light-token/create-token-account/anchor-macro/full-example.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 1. Light token accounts are Solana accounts that hold token balances of light, SPL, or Token 2022 mints. -2. Light token accounts are on-chain accounts like SPL ATA’s, but the light token program sponsors the rent-exemption cost for you. +2. Light token accounts are on-chain accounts like SPL ATA's, but the light token program sponsors the rent-exemption cost for you. + + diff --git a/light-token/cookbook/freeze-thaw.mdx b/light-token/cookbook/freeze-thaw.mdx index 3b555c2d..feb98d18 100644 --- a/light-token/cookbook/freeze-thaw.mdx +++ b/light-token/cookbook/freeze-thaw.mdx @@ -19,6 +19,7 @@ import FreezeInstructionCode from "/snippets/code-snippets/light-token/freeze-th import ThawInstructionCode from "/snippets/code-snippets/light-token/freeze-thaw/rust-client/thaw-instruction.mdx"; import FreezeAnchorProgramCode from "/snippets/code-snippets/light-token/freeze/anchor-program/full-example.mdx"; import ThawAnchorProgramCode from "/snippets/code-snippets/light-token/thaw/anchor-program/full-example.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 1. Freeze prevents all transfers or token burns from a specific Light Token account. 2. Once frozen, the account cannot send tokens, receive tokens, or be closed until it is thawed. @@ -225,3 +226,5 @@ ThawCpi { href="/light-token/cookbook/approve-revoke" horizontal /> + + diff --git a/light-token/cookbook/load-ata.mdx b/light-token/cookbook/load-ata.mdx index 57a63441..a0da7dea 100644 --- a/light-token/cookbook/load-ata.mdx +++ b/light-token/cookbook/load-ata.mdx @@ -8,6 +8,7 @@ keywords: ["load ata on solana", "get token balance for wallets"] import FullSetup from "/snippets/setup/full-setup.mdx"; import ActionCode from "/snippets/code-snippets/light-token/load-ata/action.mdx"; import InstructionCode from "/snippets/code-snippets/light-token/load-ata/instruction.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 1. `loadAta` unifies tokens from multiple sources to a single ATA: * Compressed tokens (cold Light Tokens) -> Decompresses -> light ATA @@ -39,3 +40,5 @@ Find the source code [here](https://github.com/Lightprotocol/light-protocol/blob + + diff --git a/light-token/cookbook/mint-to.mdx b/light-token/cookbook/mint-to.mdx index 2b707075..0f866cf9 100644 --- a/light-token/cookbook/mint-to.mdx +++ b/light-token/cookbook/mint-to.mdx @@ -24,6 +24,7 @@ import InstructionCode from "/snippets/code-snippets/light-token/mint-to/instruc import RustActionCode from "/snippets/code-snippets/light-token/mint-to/rust-client/action.mdx"; import RustInstructionCode from "/snippets/code-snippets/light-token/mint-to/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/mint-to/anchor-program/full-example.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 1. Mint To creates new tokens of a mint and deposits them to a specified token account. @@ -194,3 +195,5 @@ MintToCpi { href="/light-token/cookbook/transfer-interface" horizontal >
+ + diff --git a/light-token/cookbook/transfer-checked.mdx b/light-token/cookbook/transfer-checked.mdx index 6e783d05..5df57024 100644 --- a/light-token/cookbook/transfer-checked.mdx +++ b/light-token/cookbook/transfer-checked.mdx @@ -11,6 +11,7 @@ import TokenClientPrerequisites from "/snippets/light-token-guides/light-token-c import RustActionCode from "/snippets/code-snippets/light-token/transfer-checked/rust-client/action.mdx"; import RustInstructionCode from "/snippets/code-snippets/light-token/transfer-checked/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/transfer-checked/anchor-program/full-example.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 1. TransferChecked validates that the decimals parameter matches the mint's decimals. 2. Use for Light→Light transfers when you need decimal verification. @@ -128,3 +129,5 @@ TransferCheckedCpi { href="/light-token/cookbook/close-token-account" horizontal /> + + diff --git a/light-token/cookbook/transfer-interface.mdx b/light-token/cookbook/transfer-interface.mdx index 09f07a3b..3deb4903 100644 --- a/light-token/cookbook/transfer-interface.mdx +++ b/light-token/cookbook/transfer-interface.mdx @@ -22,6 +22,7 @@ import RustActionCode from "/snippets/code-snippets/light-token/transfer-interfa import RustInstructionCode from "/snippets/code-snippets/light-token/transfer-interface/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/transfer-interface/anchor-program/full-example.mdx"; import CreateAndTransferCode from "/snippets/code-snippets/light-token/transfer-interface/anchor-program/create-and-transfer-example.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; @@ -242,3 +243,5 @@ Uses the `#[light_account(init, associated_token::...)]` macro to create the des href="/light-token/cookbook/transfer-checked" horizontal /> + + diff --git a/light-token/cookbook/wrap-unwrap.mdx b/light-token/cookbook/wrap-unwrap.mdx index e8b38e21..c4e1b8c6 100644 --- a/light-token/cookbook/wrap-unwrap.mdx +++ b/light-token/cookbook/wrap-unwrap.mdx @@ -15,6 +15,7 @@ import UnwrapInstructionCode from "/snippets/code-snippets/light-token/unwrap/in import WrapRustActionCode from "/snippets/code-snippets/light-token/wrap/rust-client/action.mdx"; import UnwrapRustActionCode from "/snippets/code-snippets/light-token/unwrap/rust-client/action.mdx"; import TokenClientPrerequisites from "/snippets/light-token-guides/light-token-client-prerequisites.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; - **Wrap**: Move tokens from SPL/T22 account → Light Token ATA (hot balance) - **Unwrap**: Move tokens from Light Token ATA (hot balance) → SPL/T22 account @@ -133,3 +134,5 @@ import TokenClientPrerequisites from "/snippets/light-token-guides/light-token-c + + diff --git a/light-token/defi/programs-pinocchio.mdx b/light-token/defi/programs-pinocchio.mdx index 01fc1aed..ec6f11c6 100644 --- a/light-token/defi/programs-pinocchio.mdx +++ b/light-token/defi/programs-pinocchio.mdx @@ -3,6 +3,8 @@ title: "Pinocchio Programs" description: "Build high-performance DeFi programs with rent-free accounts using Pinocchio" --- +import AgentSkillDefiProgram from "/snippets/setup/agent-skill-defi-program.mdx"; + The Light-SDK sponsors rent-exemption for your PDAs, token accounts, and mints. Your program logic stays the same. | | Before | After | @@ -22,6 +24,9 @@ The Light-SDK sponsors rent-exemption for your PDAs, token accounts, and mints. If you use Anchor instead of Pinocchio, see [Program Integration](./programs). --- + + + Complete pinocchio Swap reference implementation: [pinocchio-swap](https://github.com/Lightprotocol/examples-light-token/tree/simplify-trait/pinocchio/swap) diff --git a/light-token/defi/programs.mdx b/light-token/defi/programs.mdx index a2fb3948..d78e16e9 100644 --- a/light-token/defi/programs.mdx +++ b/light-token/defi/programs.mdx @@ -3,6 +3,8 @@ title: "Program Integration" description: "Build high-performance DeFi programs with rent-free accounts" --- +import AgentSkillDefiProgram from "/snippets/setup/agent-skill-defi-program.mdx"; + The Light-SDK sponsors rent-exemption for your PDAs, token accounts, and mints. Your program logic stays the same. | | Before | After | @@ -25,6 +27,9 @@ macro-generated. If you don't use Anchor, see the [Pinocchio Programs](./programs-pinocchio) guide. --- + + + You can find a complete rent-free AMM reference implementation [here](https://github.com/Lightprotocol/cp-swap-reference). diff --git a/light-token/defi/routers.mdx b/light-token/defi/routers.mdx index bfcc3c3b..2f912f52 100644 --- a/light-token/defi/routers.mdx +++ b/light-token/defi/routers.mdx @@ -3,6 +3,8 @@ title: "Router Integration" description: "Add support for rent-free AMMs on Solana." --- +import AgentSkillDefiRouter from "/snippets/setup/agent-skill-defi-router.mdx"; + Your existing quoting, routing, and swap logic stays the same. The only addition: when a market has cold accounts, detect them, and prepend load instructions before the swap. @@ -16,6 +18,8 @@ The only addition: when a market has cold accounts, detect them, and prepend loa --- + + ## Detecting cold accounts Add a cache for cold accounts. This can be independent from your regular account cache. @@ -305,3 +309,4 @@ API is in Beta and subject to change. Questions or need hands-on support? [Telegram](https://t.me/swen_light) | [email](mailto:support@lightprotocol.com) | [Discord](https://discord.com/invite/7cJ8BhAXhu) + diff --git a/light-token/examples/client.mdx b/light-token/examples/client.mdx index a0c89492..56e79f08 100644 --- a/light-token/examples/client.mdx +++ b/light-token/examples/client.mdx @@ -5,7 +5,10 @@ description: "TypeScript and Rust client examples for light-token SDK." --- import ClientExamplesTable from "/snippets/overview-tables/light-token-client-examples-table.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; Find all examples on Github: [examples-light-token](https://github.com/Lightprotocol/examples-light-token) + + diff --git a/light-token/examples/program.mdx b/light-token/examples/program.mdx index d447d23c..88b0a9f6 100644 --- a/light-token/examples/program.mdx +++ b/light-token/examples/program.mdx @@ -5,7 +5,10 @@ description: "Anchor program examples for light-token CPI." --- import ProgramExamplesTable from "/snippets/overview-tables/light-token-program-examples-table.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; Find all examples on Github: [examples-light-token](https://github.com/Lightprotocol/examples-light-token) + + diff --git a/light-token/quickstart.mdx b/light-token/quickstart.mdx index 135038d6..cdbb008e 100644 --- a/light-token/quickstart.mdx +++ b/light-token/quickstart.mdx @@ -7,6 +7,7 @@ keywords: ["create tokens on solana tutorial", "mint tokens on solana guide", "s import FullSetup from "/snippets/setup/full-setup.mdx"; import MintToAction from "/snippets/code-snippets/light-token/mint-to/action.mdx"; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; @@ -44,3 +45,5 @@ import MintToAction from "/snippets/code-snippets/light-token/mint-to/action.mdx + + diff --git a/light-token/toolkits/for-payments.mdx b/light-token/toolkits/for-payments.mdx index 677473ee..0873f8aa 100644 --- a/light-token/toolkits/for-payments.mdx +++ b/light-token/toolkits/for-payments.mdx @@ -7,6 +7,8 @@ keywords: ["stablecoin payments for enterprises", "infrastructure for stablecoin import { CodeCompare } from "/snippets/jsx/code-compare.jsx"; import ToolkitsSetup from "/snippets/setup/toolkits-setup.mdx"; +import RegisterSplMint from "/snippets/setup/register-spl-mint.mdx"; +import AgentSkillPayments from "/snippets/setup/agent-skill-payments.mdx"; 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 use the same stablecoins, just stored more efficiently. @@ -64,6 +66,8 @@ import ToolkitsSetup from "/snippets/setup/toolkits-setup.mdx"; [here](https://github.com/Lightprotocol/examples-light-token/tree/main/toolkits/payments-and-wallets). + + ## Setup @@ -89,74 +93,15 @@ import { const rpc = createRpc(RPC_ENDPOINT); ``` -### One-time: Register an Existing SPL Mint + -For existing SPL mints (e.g. USDC), register the SPL interface once. This creates the omnibus PDA that holds SPL tokens when wrapped to light-token. +### Receive Payments -Find a full code example [here](https://github.com/Lightprotocol/examples-light-token/blob/main/toolkits/payments-and-wallets/register-spl-mint.ts). +Find a full code example [here](https://github.com/Lightprotocol/examples-light-token/blob/main/toolkits/payments-and-wallets/receive.ts). -Check if the interface already exists: - -```typescript -import { getSplInterfaceInfos } from "@lightprotocol/compressed-token"; - -try { - const infos = await getSplInterfaceInfos(rpc, mint); - const exists = infos.some((i) => i.isInitialized); - console.log("Interface exists:", exists); -} catch { - console.log("No interface registered for this mint."); -} -``` - -Register: - - - - -```typescript -import { Transaction, sendAndConfirmTransaction } from "@solana/web3.js"; -import { LightTokenProgram } from "@lightprotocol/compressed-token"; -import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; - -const ix = await LightTokenProgram.createSplInterface({ - feePayer: payer.publicKey, - mint, - tokenProgramId: TOKEN_PROGRAM_ID, -}); - -const tx = new Transaction().add(ix); -await sendAndConfirmTransaction(rpc, tx, [payer]); -``` - - - - -```typescript -import { createSplInterface } from "@lightprotocol/compressed-token"; - -await createSplInterface(rpc, payer, mint); -``` - - - - - - -Use `createMintInterface` with `TOKEN_PROGRAM_ID` to create a new SPL mint and register the interface in one transaction: - -```typescript -import { createMintInterface } from "@lightprotocol/compressed-token/unified"; -import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; - -const { mint } = await createMintInterface( - rpc, payer, payer, null, 9, undefined, undefined, TOKEN_PROGRAM_ID -); -``` - - +Load creates the associated token account (ATA) if needed and loads any compressed state into it. Share the ATA address with the sender. **About loading**: Light tokens reduce account rent ~200x by auto-compressing inactive @@ -166,14 +111,6 @@ atomic transaction with your regular transfer. APIs return `TransactionInstructi loop handles the rare multi-transaction case automatically. -### Receive Payments - - -Find a full code example [here](https://github.com/Lightprotocol/examples-light-token/blob/main/toolkits/payments-and-wallets/receive.ts). - - -Load creates the associated token account (ATA) if needed and loads any compressed state into it. Share the ATA address with the sender. - diff --git a/light-token/toolkits/for-privy.mdx b/light-token/toolkits/for-privy.mdx new file mode 100644 index 00000000..2c17f6ea --- /dev/null +++ b/light-token/toolkits/for-privy.mdx @@ -0,0 +1,190 @@ +--- +title: "Light-Token with Privy Wallets" +sidebarTitle: "Sign with Privy Wallet" +description: "Integrate light-token with Privy embedded wallets for rent-free token accounts and transfers." +keywords: ["privy solana", "privy light token", "embedded wallet light token", "rent-free tokens privy"] +--- +import ToolkitsSetup from "/snippets/setup/toolkits-setup.mdx"; +import RegisterSplMint from "/snippets/setup/register-spl-mint.mdx"; +import AgentSkillPayments from "/snippets/setup/agent-skill-payments.mdx"; +import TransferNodejs from "/snippets/code-snippets/privy/transfer/nodejs.mdx"; +import TransferReact from "/snippets/code-snippets/privy/transfer/react.mdx"; +import WrapNodejs from "/snippets/code-snippets/privy/wrap/nodejs.mdx"; +import WrapReact from "/snippets/code-snippets/privy/wrap/react.mdx"; +import UnwrapNodejs from "/snippets/code-snippets/privy/unwrap/nodejs.mdx"; +import UnwrapReact from "/snippets/code-snippets/privy/unwrap/react.mdx"; +import BalancesNodejs from "/snippets/code-snippets/privy/balances/nodejs.mdx"; +import BalancesReact from "/snippets/code-snippets/privy/balances/react.mdx"; +import TransactionHistoryNodejs from "/snippets/code-snippets/privy/transaction-history/nodejs.mdx"; +import TransactionHistoryReact from "/snippets/code-snippets/privy/transaction-history/react.mdx"; + +| Creation Cost | SPL | light-token | +| :---------------- | :------------------ | :------------------- | +| **Token Account** | ~2,000,000 lamports | ~**11,000** lamports | + +Privy handles user authentication and wallet management. You build transactions with light-token and Privy signs them: + +1. Authenticate with Privy +2. Build unsigned transaction +3. Sign transaction using Privy's wallet provider +4. Send signed transaction to RPC + +## What you will implement +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SPLLight
[**Transfer**](#full-code-examples)createTransferInstruction()createTransferInterfaceInstructions()
[**Wrap from SPL**](#full-code-examples)N/AcreateWrapInstruction()
[**Unwrap to SPL**](#full-code-examples)N/AcreateUnwrapInstructions()
[**Get Balance**](#get-balances)getAccount()getAtaInterface()
[**Tx History**](#get-transaction-history)getSignaturesForAddress()getSignaturesForOwnerInterface()
+ + + + + +### Prerequisites + + + +Connect to an RPC endpoint that supports ZK Compression (Helius, Triton): + +```typescript +import { createRpc } from "@lightprotocol/stateless.js"; + +import { + createTransferInterfaceInstructions, + createWrapInstruction, + createUnwrapInstructions, + getAssociatedTokenAddressInterface, + getAtaInterface, +} from "@lightprotocol/compressed-token/unified"; + +const rpc = createRpc(RPC_ENDPOINT); +``` + + + + +## Full code examples + + +Find complete examples on GitHub: [Node.js](https://github.com/Lightprotocol/examples-light-token/tree/main/privy/nodejs). + + + + + +Transfer light-tokens between wallets. Auto-loads cold (compressed) light-token, SPL or +Token-2022 balance before sending. + + +**About loading:** Light tokens reduce account rent ~200x by auto-compressing inactive accounts. +Before any action, the SDK detects compressed state and adds instructions to load it back on-chain. +This almost always fits in a single atomic transaction with your regular transfer. +APIs return `TransactionInstruction[][]` so the same loop handles the rare multi-transaction case +automatically. + + + + + + + + + + + + + + + +Wrap SPL or Token-2022 tokens into a light-token associated token account. + + + + + + + + + + + + + + +Unwrap light-token balance to SPL or Token-2022. Use unwrap to interact with applications that only support SPL/Token-2022. + + + + + + + + + + + + + + + + + +## Get balances + +Fetch SOL, hot (light-token ATA), cold (compressed), SPL, and Token-2022 balances. + + + + + + + + + + +## Get transaction history + +Fetch light-token transaction history for an owner. + + + + + + + + + + + + diff --git a/light-token/toolkits/for-streaming-mints.mdx b/light-token/toolkits/for-streaming-mints.mdx index 9ac85a1d..542bf43d 100644 --- a/light-token/toolkits/for-streaming-mints.mdx +++ b/light-token/toolkits/for-streaming-mints.mdx @@ -6,6 +6,7 @@ keywords: ["streaming mint accounts solana", "laserstream light mint", "grpc min --- import FindClosedAccounts from '/snippets/code-snippets/streaming/find-closed-accounts.mdx'; +import AgentSkillStreaming from "/snippets/setup/agent-skill-streaming.mdx"; | Event | Description | |:------|:------------| @@ -19,6 +20,8 @@ This guide is for teams building custom data pipelines (aggregators, market make If you just need account lookups, use [`get_account_interface`](/light-token/defi/routers) instead. + + ## Architecture Light mints are Solana accounts owned by the Light Token Program. The streaming diff --git a/light-token/toolkits/for-streaming-pdas.mdx b/light-token/toolkits/for-streaming-pdas.mdx index ed68074e..adc746e7 100644 --- a/light-token/toolkits/for-streaming-pdas.mdx +++ b/light-token/toolkits/for-streaming-pdas.mdx @@ -6,12 +6,16 @@ keywords: ["streaming compressible pdas solana", "laserstream pda indexing", "gr visibility: "hidden" --- +import AgentSkillStreaming from "/snippets/setup/agent-skill-streaming.mdx"; + Programs using the Light SDK expose standardized instruction discriminators for `compress_accounts_idempotent` and `decompress_accounts_idempotent`. Programs that don't implement these discriminators are not indexable with this approach. + + ## Architecture Two per-program gRPC subscriptions. Nothing else. diff --git a/light-token/toolkits/for-streaming-tokens.mdx b/light-token/toolkits/for-streaming-tokens.mdx index fc0bd7c3..7b4233eb 100644 --- a/light-token/toolkits/for-streaming-tokens.mdx +++ b/light-token/toolkits/for-streaming-tokens.mdx @@ -6,12 +6,15 @@ keywords: ["streaming token accounts solana", "laserstream light token", "grpc t --- import FindClosedAccounts from '/snippets/code-snippets/streaming/find-closed-accounts.mdx'; +import AgentSkillStreaming from "/snippets/setup/agent-skill-streaming.mdx"; This guide is for teams building custom data pipelines (aggregators, market makers). If you just need account lookups, use [`get_account_interface`](/light-token/defi/routers) instead. + + ## Architecture Light token accounts share the same base layout as SPL Token (165 bytes), so you can diff --git a/light-token/toolkits/for-wallets.mdx b/light-token/toolkits/for-wallets.mdx index 20f3047a..b02572e9 100644 --- a/light-token/toolkits/for-wallets.mdx +++ b/light-token/toolkits/for-wallets.mdx @@ -7,6 +7,7 @@ keywords: ["wallet infrastructure on solana", "scalable wallet infrastructure on import { CodeCompare } from "/snippets/jsx/code-compare.jsx"; import ToolkitsSetup from "/snippets/setup/toolkits-setup.mdx"; +import AgentSkillPayments from "/snippets/setup/agent-skill-payments.mdx"; 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 hold and receive tokens of the same mints, just stored more efficiently. @@ -64,6 +65,8 @@ import ToolkitsSetup from "/snippets/setup/toolkits-setup.mdx"; [here](https://github.com/Lightprotocol/examples-light-token/tree/main/toolkits/payments-and-wallets). + + ## Setup diff --git a/light-token/welcome.mdx b/light-token/welcome.mdx index d4a83c15..d67202cd 100644 --- a/light-token/welcome.mdx +++ b/light-token/welcome.mdx @@ -1,6 +1,6 @@ --- title: The Light Token Program -sidebarTitle: Introduction +sidebarTitle: Overview description: Light token is a high-performance token standard that reduces the cost of mint and token accounts by 200x. keywords: ["rent free tokens on solana", "rent free solana accounts", "spl token alternative for developers", "token 2022 alternative for solana", "infrastructure for stablecoin payments on solana", "scalable solana infrastructure", "token infrastructure for fintechs", "scalable infrastructure for solana apps"] --- @@ -85,7 +85,7 @@ import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; Guide to integrate light-token APIs with comparison to SPL. - + Prevent onchain instructions from being executed more than once.
@@ -96,8 +96,8 @@ import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; Guide for Wallet Applications to let users display and swap light-tokens. - - Add rent-free tokens to Privy embedded wallets. + + Add light-tokens to Privy embedded wallets. @@ -112,17 +112,6 @@ import SdkReference from "/snippets/overview-tables/sdk-reference.mdx"; -## PDA Accounts - - - - Solana PDAs with sponsored rent-exemption that can be implemented with minimal code changes. Use like any other PDA, e.g. in your DeFi program. - - - Syntax reference for #[light_account] constraints for PDA, mint, token, and associated token accounts. - - - ## Cookbook diff --git a/compressed-pdas/guides.mdx b/pda/compressed-pdas/guides.mdx similarity index 96% rename from compressed-pdas/guides.mdx rename to pda/compressed-pdas/guides.mdx index a8d89412..3980e92d 100644 --- a/compressed-pdas/guides.mdx +++ b/pda/compressed-pdas/guides.mdx @@ -79,6 +79,6 @@ Here is the complete flow to create, or interact with compressed accounts: title="Create a program with compressed accounts" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/guides/how-to-create-compressed-accounts" + href="/pda/compressed-pdas/guides/how-to-create-compressed-accounts" horizontal /> \ No newline at end of file diff --git a/compressed-pdas/guides/how-to-burn-compressed-accounts.mdx b/pda/compressed-pdas/guides/how-to-burn-compressed-accounts.mdx similarity index 96% rename from compressed-pdas/guides/how-to-burn-compressed-accounts.mdx rename to pda/compressed-pdas/guides/how-to-burn-compressed-accounts.mdx index 9ae93264..57176396 100644 --- a/compressed-pdas/guides/how-to-burn-compressed-accounts.mdx +++ b/pda/compressed-pdas/guides/how-to-burn-compressed-accounts.mdx @@ -19,7 +19,7 @@ Burning a compressed account * A burned account cannot be reinitialized. -Find [full code examples at the end](/compressed-pdas/guides/how-to-burn-compressed-accounts#full-code-example) for Anchor and native Rust. +Find [full code examples at the end](/pda/compressed-pdas/guides/how-to-burn-compressed-accounts#full-code-example) for Anchor and native Rust. # Implementation Guide @@ -247,7 +247,7 @@ The example programs below implement all steps from this guide. -For help with debugging, see the [Error Cheatsheet](../../resources/error-cheatsheet/). +For help with debugging, see the [Error Cheatsheet](/resources/error-cheatsheet). @@ -282,7 +282,7 @@ Find the source code [here](https://github.com/Lightprotocol/program-examples/tr title="Learn how to create compressed accounts" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/guides/how-to-create-compressed-accounts" + href="/pda/compressed-pdas/guides/how-to-create-compressed-accounts" horizontal /> diff --git a/compressed-pdas/guides/how-to-close-compressed-accounts.mdx b/pda/compressed-pdas/guides/how-to-close-compressed-accounts.mdx similarity index 95% rename from compressed-pdas/guides/how-to-close-compressed-accounts.mdx rename to pda/compressed-pdas/guides/how-to-close-compressed-accounts.mdx index dc547c26..03655ec5 100644 --- a/compressed-pdas/guides/how-to-close-compressed-accounts.mdx +++ b/pda/compressed-pdas/guides/how-to-close-compressed-accounts.mdx @@ -16,10 +16,10 @@ Closing a compressed account * consumes the existing account hash, and * produces a new account hash with zero values to mark it as closed. -* A closed compressed account [can be reinitialized](/compressed-pdas/guides/how-to-reinitialize-compressed-accounts). +* A closed compressed account [can be reinitialized](/pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts). -Find [full code examples at the end](/compressed-pdas/guides/how-to-close-compressed-accounts#full-code-example) for Anchor and native Rust. +Find [full code examples at the end](/pda/compressed-pdas/guides/how-to-close-compressed-accounts#full-code-example) for Anchor and native Rust. # Implementation Guide @@ -254,7 +254,7 @@ Make sure you have your developer environment set up first. -For help with debugging, see the [Error Cheatsheet](../../resources/error-cheatsheet/). +For help with debugging, see the [Error Cheatsheet](/resources/error-cheatsheet). @@ -289,7 +289,7 @@ Find the source code [here](https://github.com/Lightprotocol/program-examples/tr title="Learn how to reinitialize compressed accounts" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/guides/how-to-reinitialize-compressed-accounts" + href="/pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts" horizontal /> diff --git a/compressed-pdas/guides/how-to-create-compressed-accounts.mdx b/pda/compressed-pdas/guides/how-to-create-compressed-accounts.mdx similarity index 97% rename from compressed-pdas/guides/how-to-create-compressed-accounts.mdx rename to pda/compressed-pdas/guides/how-to-create-compressed-accounts.mdx index 987f7dea..318f8aeb 100644 --- a/compressed-pdas/guides/how-to-create-compressed-accounts.mdx +++ b/pda/compressed-pdas/guides/how-to-create-compressed-accounts.mdx @@ -16,7 +16,7 @@ Compressed accounts and addresses are created via CPI to the Light System Progra * The account hash is not persistent and changes with every write to the account. * For Solana PDA like behavior your compressed account needs an address as persistent identifier. -Find [full code examples at the end](/compressed-pdas/guides/how-to-create-compressed-accounts#full-code-example) for Anchor and native Rust. +Find [full code examples at the end](/pda/compressed-pdas/guides/how-to-create-compressed-accounts#full-code-example) for Anchor and native Rust. # Implementation Guide @@ -395,7 +395,7 @@ The example programs below implement all steps from this guide. -For help with debugging, see the [Error Cheatsheet](../../resources/error-cheatsheet/). +For help with debugging, see the [Error Cheatsheet](/resources/error-cheatsheet). @@ -430,7 +430,7 @@ Find the source code [here](https://github.com/Lightprotocol/program-examples/tr title="Learn how to update compressed accounts" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/guides/how-to-update-compressed-accounts" + href="/pda/compressed-pdas/guides/how-to-update-compressed-accounts" horizontal /> diff --git a/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx b/pda/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx similarity index 100% rename from compressed-pdas/guides/how-to-create-nullifier-pdas.mdx rename to pda/compressed-pdas/guides/how-to-create-nullifier-pdas.mdx diff --git a/compressed-pdas/guides/how-to-reinitialize-compressed-accounts.mdx b/pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts.mdx similarity index 96% rename from compressed-pdas/guides/how-to-reinitialize-compressed-accounts.mdx rename to pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts.mdx index c49b22e7..971ff72c 100644 --- a/compressed-pdas/guides/how-to-reinitialize-compressed-accounts.mdx +++ b/pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts.mdx @@ -18,7 +18,7 @@ An empty compressed account can be reinitialized * to create a new account hash at the same address with new values. -Find [full code examples at the end](/compressed-pdas/guides/how-to-reinitialize-compressed-accounts#full-code-example) for Anchor and native Rust. +Find [full code examples at the end](/pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts#full-code-example) for Anchor and native Rust. # Implementation Guide @@ -239,7 +239,7 @@ The counter programs below implement all steps from this guide. -For help with debugging, see the [Error Cheatsheet](../../resources/error-cheatsheet/). +For help with debugging, see the [Error Cheatsheet](/resources/error-cheatsheet). @@ -274,7 +274,7 @@ Find the source code [here](https://github.com/Lightprotocol/program-examples/tr title="Learn how to burn compressed accounts" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/guides/how-to-burn-compressed-accounts" + href="/pda/compressed-pdas/guides/how-to-burn-compressed-accounts" horizontal /> diff --git a/compressed-pdas/guides/how-to-update-compressed-accounts.mdx b/pda/compressed-pdas/guides/how-to-update-compressed-accounts.mdx similarity index 96% rename from compressed-pdas/guides/how-to-update-compressed-accounts.mdx rename to pda/compressed-pdas/guides/how-to-update-compressed-accounts.mdx index 92cc7986..77214490 100644 --- a/compressed-pdas/guides/how-to-update-compressed-accounts.mdx +++ b/pda/compressed-pdas/guides/how-to-update-compressed-accounts.mdx @@ -19,7 +19,7 @@ The update of a compressed account follows a UTXO pattern, unlike regular Solana * The existing account hash is nullified to prevent double spending. -Find [full code examples at the end](/compressed-pdas/guides/how-to-update-compressed-accounts#full-code-example) for Anchor and native Rust. +Find [full code examples at the end](/pda/compressed-pdas/guides/how-to-update-compressed-accounts#full-code-example) for Anchor and native Rust. # Implementation Guide @@ -256,7 +256,7 @@ The example programs below implement all steps from this guide. -For help with debugging, see the [Error Cheatsheet](../../resources/error-cheatsheet/). +For help with debugging, see the [Error Cheatsheet](/resources/error-cheatsheet). @@ -291,7 +291,7 @@ Find the source code [here](https://github.com/Lightprotocol/program-examples/tr title="Learn how to close compressed accounts" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/guides/how-to-close-compressed-accounts" + href="/pda/compressed-pdas/guides/how-to-close-compressed-accounts" horizontal /> diff --git a/compressed-pdas/overview.mdx b/pda/compressed-pdas/overview.mdx similarity index 100% rename from compressed-pdas/overview.mdx rename to pda/compressed-pdas/overview.mdx diff --git a/compressed-pdas/program-examples.mdx b/pda/compressed-pdas/program-examples.mdx similarity index 99% rename from compressed-pdas/program-examples.mdx rename to pda/compressed-pdas/program-examples.mdx index 7bdf37fc..e47944f1 100644 --- a/compressed-pdas/program-examples.mdx +++ b/pda/compressed-pdas/program-examples.mdx @@ -62,6 +62,6 @@ Full compressed account lifecycle (create, increment, decrement, reset, close): title="Follow our guides to these program examples" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/guides" + href="/pda/compressed-pdas/guides" horizontal /> \ No newline at end of file diff --git a/compressed-pdas/solana-attestation-service.mdx b/pda/compressed-pdas/solana-attestation-service.mdx similarity index 100% rename from compressed-pdas/solana-attestation-service.mdx rename to pda/compressed-pdas/solana-attestation-service.mdx diff --git a/light-token/light-pda.mdx b/pda/light-pda/overview.mdx similarity index 94% rename from light-token/light-pda.mdx rename to pda/light-pda/overview.mdx index efa6395d..a830ae94 100644 --- a/light-token/light-pda.mdx +++ b/pda/light-pda/overview.mdx @@ -1,19 +1,19 @@ --- title: "Light PDA" -description: "Create PDA accounts with sponsored rent-exemption for Anchor programs. Works with your existing Anchor implementations." +description: "Create Solana PDA accounts with sponsored rent-exemption and minimal code changes. Works with your existing Anchor implementations." --- import FullCounterExample from '/snippets/code-snippets/light-token/counter/anchor-macro/full-example.mdx'; +import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; -Light-PDAs are Solana PDAs with sponsored rent-exemption. -Programs create them using Anchor `#[account(init)]` with `#[light_account(init)]`. - -| | Regular PDA | Light-PDA | +| Creation Cost | Regular PDA | Light-PDA | |------------------|----------------------|-----------------| | 100-byte account | ~1,600,000 lamports | ~11,500 lamports | ## What changes +Audit overhead is minimal as your program logic is mostly untouched. The rest is macro-generated. + | Area | Change | |------|--------| | State struct | Derive `LightAccount`, add `compression_info: CompressionInfo` | @@ -21,9 +21,6 @@ Programs create them using Anchor `#[account(init)]` with `#[light_account(init) | Program module | Add `#[light_program]` above `#[program]` | | Instructions (reads, updates, closes) | No program changes. Client prepends a load instruction if account is cold. | -Audit overhead is minimal as your program logic is mostly untouched. The rest is -macro-generated. - --- ## Step 1: Dependencies @@ -194,3 +191,5 @@ API is in Beta and subject to change. Questions or need hands-on support? [Telegram](https://t.me/swen_light) | [email](mailto:support@lightprotocol.com) | [Discord](https://discord.com/invite/7cJ8BhAXhu) + + diff --git a/light-token/pda-overview.mdx b/pda/overview.mdx similarity index 64% rename from light-token/pda-overview.mdx rename to pda/overview.mdx index c00e0044..60754708 100644 --- a/light-token/pda-overview.mdx +++ b/pda/overview.mdx @@ -7,8 +7,8 @@ import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx ## Light-PDA -Light-PDAs are Solana PDAs with sponsored rent-exemption created using Anchor `#[account(init)]` with `#[light_account(init)]`. -Can be implemented with minimal code changes to your existing Solana program and leaves program logic mostly untouched. +Light-PDAs are Solana PDAs with sponsored rent-exemption and can be implemented with minimal code changes to your existing Solana program. +Your program logic stays mostly untouched, which keeps audit overhead minimal. > Use like any other PDA, e.g. in your DeFi program. @@ -20,11 +20,7 @@ Can be implemented with minimal code changes to your existing Solana program and -- Standard Anchor account type (`Account<'info, T>`) -- Reads, updates, and closes are unchanged -- Inactive accounts auto-compress; clients load them back when needed - - + --- @@ -40,7 +36,4 @@ Fully compatible with existing Solana programs, but requires custom logic. |------------------|----------------------|-----------------| | 100-byte account | ~1,600,000 lamports | 15,000 lamports | -- Derived using a program address and seed, like regular PDAs -- Compressed state requires a validity proof for every read and write (fetched by client from RPC that supports ZK Compression, such as Helius and Triton) - - \ No newline at end of file + \ No newline at end of file diff --git a/references/migration-v1-to-v2.mdx b/references/migration-v1-to-v2.mdx index f89b9580..fececb7c 100644 --- a/references/migration-v1-to-v2.mdx +++ b/references/migration-v1-to-v2.mdx @@ -335,6 +335,6 @@ const remainingAccounts = PackedAccounts.newWithSystemAccountsV2(systemAccountCo title="Program examples" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/program-examples" + href="/pda/compressed-pdas/program-examples" horizontal /> diff --git a/references/terminology.mdx b/references/terminology.mdx index 44aceaf9..c84525e2 100644 --- a/references/terminology.mdx +++ b/references/terminology.mdx @@ -100,7 +100,7 @@ A 32-byte identifier that uniquely represents a compressed account's state, stor Compressed accounts with an address stored in an address Merkle tree. Full Solana PDA functionality and composability without rent-exemption. -> [Docs](/compressed-pdas/overview) +> [Docs](/pda/compressed-pdas/overview) ## Compressed token @@ -203,7 +203,7 @@ A helpful analogy to differentiate Solana ledger and state: A Solana PDA with sponsored rent-exemption. Programs create Light-PDAs using Anchor `#[account(init)]` with `#[light_account(init)]`. Compresses automatically after extended inactivity; clients load the account back when it's accessed again. Program logic does not change for reads, updates, or closes. Only the init instruction and state struct require additions. -> [Docs](/light-token/light-pda) | [Overview](/light-token/pda-overview) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter) +> [Docs](/pda/light-pda/overview) | [Overview](/pda/overview) | [Example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter) ## Light System Program @@ -300,7 +300,7 @@ The documentation provides two implementations with rent-free PDA accounts: | **Rust SDK** | [light-nullifier-program](https://crates.io/crates/light-nullifier-program) | | **TypeScript SDK** | [@lightprotocol/nullifier-program](https://www.npmjs.com/package/@lightprotocol/nullifier-program) | -> [Docs](/compressed-pdas/guides/how-to-create-nullifier-pdas) | [Skill](https://github.com/Lightprotocol/skills/tree/main/skills/payments-and-wallets) | [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/actions/create_nullifier.rs) +> [Docs](/pda/compressed-pdas/guides/how-to-create-nullifier-pdas) | [Skill](https://github.com/Lightprotocol/skills/tree/main/skills/payments-and-wallets) | [Example](https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/actions/create_nullifier.rs) **ZK nullifier** — For ZK or privacy-preserving programs on Solana to prevent double-spending. Can be integrated with minimal code changes. diff --git a/resources/addresses-and-urls.mdx b/resources/addresses-and-urls.mdx index e71c08bb..ad27ccf6 100644 --- a/resources/addresses-and-urls.mdx +++ b/resources/addresses-and-urls.mdx @@ -186,7 +186,7 @@ main(); title="Compressed PDAs" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/overview" + href="/pda/compressed-pdas/overview" horizontal /> diff --git a/resources/cli-installation.mdx b/resources/cli-installation.mdx index b29b6b37..d8a27652 100644 --- a/resources/cli-installation.mdx +++ b/resources/cli-installation.mdx @@ -253,7 +253,7 @@ FLAGS title="Build with compressed PDAs" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/overview" + href="/pda/compressed-pdas/overview" horizontal /> diff --git a/resources/sdks/program-development.mdx b/resources/sdks/program-development.mdx index 7ae55b87..1b5c8b5d 100644 --- a/resources/sdks/program-development.mdx +++ b/resources/sdks/program-development.mdx @@ -50,14 +50,14 @@ Build your own program or view program examples. title="Program Guides" icon="chevron-right" color="#0066ff" - href="/compressed-pdas/guides" + href="/pda/compressed-pdas/guides" horizontal /> \ No newline at end of file diff --git a/snippets/code-snippets/privy/balances/nodejs.mdx b/snippets/code-snippets/privy/balances/nodejs.mdx index ebf6e51d..0fcafdb2 100644 --- a/snippets/code-snippets/privy/balances/nodejs.mdx +++ b/snippets/code-snippets/privy/balances/nodejs.mdx @@ -1,38 +1,134 @@ ```typescript -import {PublicKey} from '@solana/web3.js'; +import 'dotenv/config'; +import {PublicKey, LAMPORTS_PER_SOL} from '@solana/web3.js'; +import {TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID} from '@solana/spl-token'; import {createRpc} from '@lightprotocol/stateless.js'; -import {HELIUS_RPC_URL} from './config.js'; +import { + getAtaInterface, + getAssociatedTokenAddressInterface, +} from '@lightprotocol/compressed-token/unified'; +interface BalanceBreakdown { + sol: number; + token?: { + mint: string; + unified: number; + decimals: number; + hot: number; + cold: number; + spl: number; + t22: number; + }; +} -export async function getCompressedBalances(ownerAddress: string) { - const rpc = createRpc(HELIUS_RPC_URL); +export async function getBalances( + ownerAddress: string, + mintAddress?: string, +): Promise { + const rpc = createRpc(process.env.HELIUS_RPC_URL!); const owner = new PublicKey(ownerAddress); - // Get compressed SOL balance - const compressedSol = await rpc.getCompressedBalanceByOwner(owner); - const compressedSolLamports = compressedSol.value ? BigInt(compressedSol.value.toString()) : 0n; - - // Get compressed token accounts (filter out null items from indexer) - const compressedAccounts = await rpc.getCompressedTokenAccountsByOwner(owner); - const validItems = (compressedAccounts.items || []).filter((item): item is NonNullable => item !== null); - - // Aggregate balances by mint - const balances = new Map(); - for (const account of validItems) { - if (account.parsed) { - const mint = account.parsed.mint.toBase58(); - const amount = BigInt(account.parsed.amount.toString()); - const current = balances.get(mint) || 0n; - balances.set(mint, current + amount); - } + // SOL balance + let solLamports = 0; + try { + solLamports = await rpc.getBalance(owner); + } catch (e) { + console.error('Failed to fetch SOL balance:', e); + } + + const result: BalanceBreakdown = { + sol: solLamports / LAMPORTS_PER_SOL, + }; + + if (!mintAddress) { + return result; } - return { - sol: compressedSolLamports.toString(), - tokens: Array.from(balances.entries()).map(([mint, amount]) => ({ + const mint = new PublicKey(mintAddress); + const ata = getAssociatedTokenAddressInterface(mint, owner); + + const decimals = 9; + let hot = 0; + let cold = 0; + let spl = 0; + let t22 = 0; + + // 1. Hot balance (light-token associated token account on-chain) + try { + const {parsed} = await getAtaInterface(rpc, ata, owner, mint); + hot = toUiAmount(parsed.amount, decimals); + } catch { + // Associated token account may not exist yet + } + + // 2. Cold balance (compressed token accounts) + try { + const compressed = await rpc.getCompressedTokenBalancesByOwnerV2(owner, { mint, - amount: amount.toString(), - accounts: validItems.filter(a => a.parsed?.mint.toBase58() === mint).length - })) + }); + for (const item of compressed.value.items) { + cold += toUiAmount(item.balance, decimals); + } + } catch { + // No compressed accounts + } + + // 3. SPL balance (standard token program accounts) + try { + const splAccounts = await rpc.getTokenAccountsByOwner(owner, { + programId: TOKEN_PROGRAM_ID, + }); + for (const {account} of splAccounts.value) { + const buf = toBuffer(account.data); + if (!buf || buf.length < 72) continue; + const accountMint = new PublicKey(buf.subarray(0, 32)); + if (!accountMint.equals(mint)) continue; + spl += toUiAmount(buf.readBigUInt64LE(64), decimals); + } + } catch { + // No SPL accounts + } + + // 4. T22 balance (Token-2022 accounts) + try { + const t22Accounts = await rpc.getTokenAccountsByOwner(owner, { + programId: TOKEN_2022_PROGRAM_ID, + }); + for (const {account} of t22Accounts.value) { + const buf = toBuffer(account.data); + if (!buf || buf.length < 72) continue; + const accountMint = new PublicKey(buf.subarray(0, 32)); + if (!accountMint.equals(mint)) continue; + t22 += toUiAmount(buf.readBigUInt64LE(64), decimals); + } + } catch { + // No T22 accounts + } + + const unified = hot + cold; + + result.token = { + mint: mintAddress, + unified, + decimals, + hot, + cold, + spl, + t22, }; + + return result; +} + +function toBuffer(data: Buffer | Uint8Array | string | unknown): Buffer | null { + if (data instanceof Buffer) return data; + if (data instanceof Uint8Array) return Buffer.from(data); + return null; } + +function toUiAmount(raw: bigint | {toNumber: () => number}, decimals: number): number { + const value = typeof raw === 'bigint' ? Number(raw) : raw.toNumber(); + return value / 10 ** decimals; +} + +export default getBalances; ``` diff --git a/snippets/code-snippets/privy/balances/react.mdx b/snippets/code-snippets/privy/balances/react.mdx index cd6310f8..d76d7a57 100644 --- a/snippets/code-snippets/privy/balances/react.mdx +++ b/snippets/code-snippets/privy/balances/react.mdx @@ -1,174 +1 @@ -```typescript -import { useState, useCallback } from 'react'; -import { PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js'; -import { getAccount, getAssociatedTokenAddressSync } from '@solana/spl-token'; -import { createRpc } from '@lightprotocol/stateless.js'; - -const USDC_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'; -const TEST_MINT = '7cT3PeXyDLkyEcvr9YzsjGLuZneKsea4c8hPbJQEjMCZ'; - -export interface TokenBalance { - mint: string; - amount: string; - decimals: number; - isCompressed: boolean; - isNative: boolean; -} - -export function useCompressedBalances() { - const [balances, setBalances] = useState([]); - const [isLoading, setIsLoading] = useState(false); - - const fetchBalances = useCallback(async (ownerAddress: string) => { - if (!ownerAddress) return; - - setIsLoading(true); - try { - const rpc = createRpc(import.meta.env.VITE_HELIUS_RPC_URL); - const owner = new PublicKey(ownerAddress); - const allBalances: TokenBalance[] = []; - - // Get compressed SOL balance - try { - const compressedSol = await rpc.getCompressedBalanceByOwner(owner); - if (compressedSol && BigInt(compressedSol.toString()) > 0n) { - allBalances.push({ - mint: 'So11111111111111111111111111111111111111112', - amount: compressedSol.toString(), - decimals: 9, - isCompressed: true, - isNative: true, - }); - } - } catch { - // No compressed SOL - } - - // Get regular SOL balance - try { - const solBalance = await rpc.getBalance(owner); - allBalances.push({ - mint: 'So11111111111111111111111111111111111111112', - amount: solBalance.toString(), - decimals: 9, - isCompressed: false, - isNative: true, - }); - } catch { - // Failed to get SOL balance - } - - // Get regular SPL token accounts - try { - const tokenAccounts = await rpc.getTokenAccountsByOwner(owner, { - programId: new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'), - }); - - for (const { account, pubkey } of tokenAccounts.value) { - const data = account.data; - if (data instanceof Buffer || (typeof data === 'object' && 'length' in data)) { - // Parse token account data - const dataBuffer = Buffer.from(data as Uint8Array); - if (dataBuffer.length >= 72) { - const mint = new PublicKey(dataBuffer.subarray(0, 32)); - const amount = dataBuffer.readBigUInt64LE(64); - - // Get mint info for decimals - try { - const mintInfo = await rpc.getAccountInfo(mint); - const decimals = mintInfo?.data ? (mintInfo.data as Buffer)[44] || 6 : 6; - - allBalances.push({ - mint: mint.toBase58(), - amount: amount.toString(), - decimals, - isCompressed: false, - isNative: false, - }); - } catch { - allBalances.push({ - mint: mint.toBase58(), - amount: amount.toString(), - decimals: 6, - isCompressed: false, - isNative: false, - }); - } - } - } - } - } catch { - // Failed to get token accounts - } - - // Get compressed token accounts - try { - const compressedAccounts = await rpc.getCompressedTokenAccountsByOwner(owner); - - if (compressedAccounts?.items) { - const mintAmounts = new Map(); - const mintDecimals = new Map(); - - for (const item of compressedAccounts.items) { - if (item?.parsed?.mint && item?.parsed?.amount) { - const mint = item.parsed.mint.toBase58(); - const amount = BigInt(item.parsed.amount.toString()); - const current = mintAmounts.get(mint) || 0n; - mintAmounts.set(mint, current + amount); - - // Store decimals (assume 6 for now, could fetch from mint) - if (!mintDecimals.has(mint)) { - mintDecimals.set(mint, 6); - } - } - } - - for (const [mint, amount] of mintAmounts) { - allBalances.push({ - mint, - amount: amount.toString(), - decimals: mintDecimals.get(mint) || 6, - isCompressed: true, - isNative: false, - }); - } - } - } catch { - // Failed to get compressed accounts - } - - // Add fallback tokens with 0 balance if not present - const hasMint = (mint: string) => allBalances.some(b => b.mint === mint); - - if (!hasMint(USDC_MINT)) { - allBalances.push({ - mint: USDC_MINT, - amount: '0', - decimals: 6, - isCompressed: false, - isNative: false, - }); - } - - if (!hasMint(TEST_MINT)) { - allBalances.push({ - mint: TEST_MINT, - amount: '0', - decimals: 6, - isCompressed: false, - isNative: false, - }); - } - - setBalances(allBalances); - } catch (error) { - console.error('Failed to fetch balances:', error); - setBalances([]); - } finally { - setIsLoading(false); - } - }, []); - - return { balances, isLoading, fetchBalances }; -} -``` +React example coming soon. diff --git a/snippets/code-snippets/privy/compress/nodejs.mdx b/snippets/code-snippets/privy/compress/nodejs.mdx deleted file mode 100644 index 41e41a3f..00000000 --- a/snippets/code-snippets/privy/compress/nodejs.mdx +++ /dev/null @@ -1,89 +0,0 @@ -```typescript -import 'dotenv/config'; -import {PrivyClient} from '@privy-io/node'; -import {createRpc, bn, selectStateTreeInfo} from '@lightprotocol/stateless.js'; -import {PublicKey, Transaction, ComputeBudgetProgram} from '@solana/web3.js'; -import {getAssociatedTokenAddressSync, getAccount} from '@solana/spl-token'; -import {LightTokenProgram, getTokenPoolInfos, selectTokenPoolInfo} from '@lightprotocol/compressed-token'; - -const compressTokens = async ( - fromAddress: string, - toAddress: string, - tokenMintAddress: string, - amount: number, - decimals: number = 6 -) => { - const connection = createRpc(process.env.HELIUS_RPC_URL!); - - const privy = new PrivyClient({ - appId: process.env.PRIVY_APP_ID!, - appSecret: process.env.PRIVY_APP_SECRET!, - }); - - // Create public key objects - const fromPubkey = new PublicKey(fromAddress); - const toPubkey = new PublicKey(toAddress); - const mintPubkey = new PublicKey(tokenMintAddress); - const tokenAmount = bn(amount * Math.pow(10, decimals)); - - // Get source token account and verify balance - const ownerAta = getAssociatedTokenAddressSync(mintPubkey, fromPubkey); - const ataAccount = await getAccount(connection, ownerAta); - if (ataAccount.amount < BigInt(tokenAmount.toString())) { - throw new Error('Insufficient SPL balance'); - } - - // Get state tree to store compressed tokens - // Get SPL interface info. SPL tokens are stored in the interface PDA when compressed. - const stateTreeInfos = await connection.getStateTreeInfos(); - const selectedTreeInfo = selectStateTreeInfo(stateTreeInfos); - const tokenPoolInfos = await getTokenPoolInfos(connection, mintPubkey); - const tokenPoolInfo = selectTokenPoolInfo(tokenPoolInfos); - - // Create compress instruction - const instruction = await LightTokenProgram.compress({ - payer: fromPubkey, - owner: fromPubkey, - source: ownerAta, - toAddress: toPubkey, - mint: mintPubkey, - amount: tokenAmount, - outputStateTreeInfo: selectedTreeInfo, - tokenPoolInfo, - }); - - // Create transaction - const transaction = new Transaction(); - transaction.add(ComputeBudgetProgram.setComputeUnitLimit({units: 300_000})); - transaction.add(instruction); - - // Get recent blockhash - const {blockhash} = await connection.getLatestBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = fromPubkey; - - // Sign with Privy - const signResult = await privy.wallets().solana().signTransaction(process.env.TREASURY_WALLET_ID!, { - transaction: transaction.serialize({requireAllSignatures: false}), - authorization_context: { - authorization_private_keys: [process.env.TREASURY_AUTHORIZATION_KEY!] - } - }); - const signedTx = (signResult as any).signed_transaction || signResult.signedTransaction; - if (!signedTx) { - throw new Error('Privy returned invalid response: ' + JSON.stringify(signResult)); - } - const signedTransaction = Buffer.from(signedTx, 'base64'); - - // Send transaction - const signature = await connection.sendRawTransaction(signedTransaction, { - skipPreflight: false, - preflightCommitment: 'confirmed' - }); - await connection.confirmTransaction(signature, 'confirmed'); - - return signature; -}; - -export default compressTokens; -``` diff --git a/snippets/code-snippets/privy/compress/react.mdx b/snippets/code-snippets/privy/compress/react.mdx deleted file mode 100644 index 5adfc1e4..00000000 --- a/snippets/code-snippets/privy/compress/react.mdx +++ /dev/null @@ -1,106 +0,0 @@ -```typescript -import { useState } from 'react'; -import { PublicKey, Transaction, ComputeBudgetProgram } from '@solana/web3.js'; -import { getAssociatedTokenAddressSync, getAccount } from '@solana/spl-token'; -import { bn, createRpc, selectStateTreeInfo } from '@lightprotocol/stateless.js'; -import { LightTokenProgram, getTokenPoolInfos, selectTokenPoolInfo } from '@lightprotocol/compressed-token'; -import type { ConnectedStandardSolanaWallet } from '@privy-io/js-sdk-core'; -import type { SignTransactionResult } from '@privy-io/react-auth/solana'; - -export interface CompressParams { - ownerPublicKey: string; - toAddress: string; - mint: string; - amount: number; - decimals?: number; -} - -export interface CompressArgs { - params: CompressParams; - wallet: ConnectedStandardSolanaWallet; - signTransaction: (args: { - transaction: Buffer; - wallet: ConnectedStandardSolanaWallet; - chain: string; - }) => Promise; -} - -export function useCompress() { - const [isLoading, setIsLoading] = useState(false); - - const compress = async (args: CompressArgs): Promise => { - setIsLoading(true); - - try { - const { params, wallet, signTransaction } = args; - const { ownerPublicKey, toAddress, mint, amount, decimals = 6 } = params; - - // Create RPC connection - const rpc = createRpc(import.meta.env.VITE_HELIUS_RPC_URL); - - // Create public key objects - const ownerPubkey = new PublicKey(ownerPublicKey); - const toPubkey = new PublicKey(toAddress); - const mintPubkey = new PublicKey(mint); - const tokenAmount = bn(amount * Math.pow(10, decimals)); - - // Get source token account and verify balance - const ownerAta = getAssociatedTokenAddressSync(mintPubkey, ownerPubkey); - const ataAccount = await getAccount(rpc, ownerAta); - if (ataAccount.amount < BigInt(tokenAmount.toString())) { - throw new Error('Insufficient SPL balance'); - } - - // Get state tree to store compressed tokens - // Get SPL interface info. SPL tokens are stored in the interface PDA when compressed. - const stateTreeInfos = await rpc.getStateTreeInfos(); - const selectedTreeInfo = selectStateTreeInfo(stateTreeInfos); - const tokenPoolInfos = await getTokenPoolInfos(rpc, mintPubkey); - const tokenPoolInfo = selectTokenPoolInfo(tokenPoolInfos); - - // Create compress instruction - const instruction = await LightTokenProgram.compress({ - payer: ownerPubkey, - owner: ownerPubkey, - source: ownerAta, - toAddress: toPubkey, - mint: mintPubkey, - amount: tokenAmount, - outputStateTreeInfo: selectedTreeInfo, - tokenPoolInfo, - }); - - // Build transaction - const { blockhash } = await rpc.getLatestBlockhash(); - const transaction = new Transaction(); - transaction.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 })); - transaction.add(instruction); - transaction.recentBlockhash = blockhash; - transaction.feePayer = ownerPubkey; - - // Serialize unsigned transaction - const unsignedTxBuffer = transaction.serialize({ requireAllSignatures: false }); - - // Sign with Privy - const signedTx = await signTransaction({ - transaction: unsignedTxBuffer, - wallet, - chain: 'solana:devnet', - }); - - // Send transaction - const signedTxBuffer = Buffer.from(signedTx.signedTransaction); - const signature = await rpc.sendRawTransaction(signedTxBuffer, { - skipPreflight: false, - preflightCommitment: 'confirmed', - }); - - return signature; - } finally { - setIsLoading(false); - } - }; - - return { compress, isLoading }; -} -``` diff --git a/snippets/code-snippets/privy/decompress/nodejs.mdx b/snippets/code-snippets/privy/decompress/nodejs.mdx deleted file mode 100644 index 6f722014..00000000 --- a/snippets/code-snippets/privy/decompress/nodejs.mdx +++ /dev/null @@ -1,81 +0,0 @@ -```typescript -import 'dotenv/config'; -import {PrivyClient} from '@privy-io/node'; -import {createRpc} from '@lightprotocol/stateless.js'; -import {Keypair, PublicKey, Transaction} from '@solana/web3.js'; -import {getAssociatedTokenAddressSync, createAssociatedTokenAccount} from '@solana/spl-token'; -import {decompress} from '@lightprotocol/compressed-token'; - -const decompressTokens = async ( - fromAddress: string, - tokenMintAddress: string, - amount: number, - decimals: number = 6 -) => { - const connection = createRpc(process.env.HELIUS_RPC_URL!); - - const privy = new PrivyClient({ - appId: process.env.PRIVY_APP_ID!, - appSecret: process.env.PRIVY_APP_SECRET!, - }); - - const fromPubkey = new PublicKey(fromAddress); - const mintPubkey = new PublicKey(tokenMintAddress); - const rawAmount = amount * Math.pow(10, decimals); - - // Get destination ATA - const ownerAta = getAssociatedTokenAddressSync(mintPubkey, fromPubkey); - - // Check ATA exists (decompress action will handle creation internally) - // But we need to be aware ATA creation requires a separate signer - - // Create fake keypair for decompress action (only publicKey is used) - const dummyPayer = { - publicKey: fromPubkey, - secretKey: new Uint8Array(64), - } as any; - - // Intercept sendAndConfirmTransaction to use Privy signing - const originalSendAndConfirm = (connection as any).sendAndConfirmTransaction; - (connection as any).sendAndConfirmTransaction = async (tx: Transaction, signers: any[]) => { - const signResult = await privy.wallets().solana().signTransaction(process.env.TREASURY_WALLET_ID!, { - transaction: tx.serialize({requireAllSignatures: false}), - authorization_context: { - authorization_private_keys: [process.env.TREASURY_AUTHORIZATION_KEY!] - } - }); - - const signedTx = (signResult as any).signed_transaction || signResult.signedTransaction; - if (!signedTx) { - throw new Error('Privy returned invalid response'); - } - - const signedTransaction = Buffer.from(signedTx, 'base64'); - const signature = await connection.sendRawTransaction(signedTransaction, { - skipPreflight: false, - preflightCommitment: 'confirmed' - }); - await connection.confirmTransaction(signature, 'confirmed'); - return signature; - }; - - try { - // Use high-level decompress action (handles account configuration correctly) - const signature = await decompress( - connection, - dummyPayer, - mintPubkey, - rawAmount, - dummyPayer, - ownerAta - ); - - return signature; - } finally { - // Restore original function - (connection as any).sendAndConfirmTransaction = originalSendAndConfirm; - } -}; - -export default decompressTokens; -``` diff --git a/snippets/code-snippets/privy/decompress/react.mdx b/snippets/code-snippets/privy/decompress/react.mdx deleted file mode 100644 index 193761e8..00000000 --- a/snippets/code-snippets/privy/decompress/react.mdx +++ /dev/null @@ -1,124 +0,0 @@ -```typescript -import { useState } from 'react'; -import { PublicKey, Transaction, ComputeBudgetProgram } from '@solana/web3.js'; -import { getAssociatedTokenAddressSync, createAssociatedTokenAccountInstruction, getAccount, TokenAccountNotFoundError } from '@solana/spl-token'; -import { LightTokenProgram, selectMinCompressedTokenAccountsForTransfer, getSplInterfaceInfos, selectSplInterfaceInfosForDecompression } from '@lightprotocol/compressed-token'; -import { bn, createRpc } from '@lightprotocol/stateless.js'; -import type { ConnectedStandardSolanaWallet } from '@privy-io/js-sdk-core'; -import type { SignTransactionResult } from '@privy-io/react-auth/solana'; - -export interface DecompressParams { - ownerPublicKey: string; - mint: string; - amount: number; - decimals?: number; -} - -export interface DecompressArgs { - params: DecompressParams; - wallet: ConnectedStandardSolanaWallet; - signTransaction: (args: { - transaction: Buffer; - wallet: ConnectedStandardSolanaWallet; - chain: string; - }) => Promise; -} - -export function useDecompress() { - const [isLoading, setIsLoading] = useState(false); - - const decompress = async (args: DecompressArgs): Promise => { - setIsLoading(true); - - try { - const { params, wallet, signTransaction } = args; - const { ownerPublicKey, mint, amount, decimals = 6 } = params; - - // Create RPC connection - const rpc = createRpc(import.meta.env.VITE_HELIUS_RPC_URL); - - const owner = new PublicKey(ownerPublicKey); - const mintPubkey = new PublicKey(mint); - const tokenAmount = bn(Math.floor(amount * Math.pow(10, decimals))); - - // Get destination ATA - const destinationAta = getAssociatedTokenAddressSync(mintPubkey, owner); - - // Get compressed token accounts - const accounts = await rpc.getCompressedTokenAccountsByOwner(owner, { mint: mintPubkey }); - if (!accounts.items || accounts.items.length === 0) { - throw new Error('No compressed token accounts found'); - } - - // Select minimum accounts needed - const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(accounts.items, tokenAmount); - if (inputAccounts.length === 0) { - throw new Error('Insufficient compressed balance'); - } - - // Get validity proof and SPL interface info - const proof = await rpc.getValidityProof( - inputAccounts.map((account) => bn(account.compressedAccount.hash)) - ); - const splInterfaceInfos = await getSplInterfaceInfos(rpc, mintPubkey); - const tokenPoolInfos = selectSplInterfaceInfosForDecompression(splInterfaceInfos, tokenAmount); - - // Build transaction - const { blockhash } = await rpc.getLatestBlockhash(); - const transaction = new Transaction(); - transaction.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 400_000 })); - - // Create ATA if needed - try { - await getAccount(rpc, destinationAta); - } catch (e) { - if (e instanceof TokenAccountNotFoundError) { - transaction.add( - createAssociatedTokenAccountInstruction(owner, destinationAta, owner, mintPubkey) - ); - } else { - throw e; - } - } - - // Build decompress instruction - const decompressIx = await LightTokenProgram.decompress({ - payer: owner, - inputCompressedTokenAccounts: inputAccounts, - toAddress: destinationAta, - amount: tokenAmount, - recentInputStateRootIndices: proof.rootIndices, - recentValidityProof: proof.compressedProof, - tokenPoolInfos, - }); - - transaction.add(decompressIx); - transaction.recentBlockhash = blockhash; - transaction.feePayer = owner; - - // Serialize unsigned transaction - const unsignedTxBuffer = transaction.serialize({ requireAllSignatures: false }); - - // Sign with Privy - const signedTx = await signTransaction({ - transaction: unsignedTxBuffer, - wallet, - chain: 'solana:devnet', - }); - - // Send transaction - const signedTxBuffer = Buffer.from(signedTx.signedTransaction); - const signature = await rpc.sendRawTransaction(signedTxBuffer, { - skipPreflight: false, - preflightCommitment: 'confirmed', - }); - - return signature; - } finally { - setIsLoading(false); - } - }; - - return { decompress, isLoading }; -} -``` diff --git a/snippets/code-snippets/privy/transaction-history/nodejs.mdx b/snippets/code-snippets/privy/transaction-history/nodejs.mdx index 9d58855f..994de4bc 100644 --- a/snippets/code-snippets/privy/transaction-history/nodejs.mdx +++ b/snippets/code-snippets/privy/transaction-history/nodejs.mdx @@ -6,60 +6,32 @@ import {PublicKey} from '@solana/web3.js'; const getTransactionHistory = async ( ownerAddress: string, limit: number = 10, - includeDetails: boolean = false ) => { const connection = createRpc(process.env.HELIUS_RPC_URL!); const owner = new PublicKey(ownerAddress); - // Get compression signatures for token owner - const signatures = await connection.getCompressionSignaturesForTokenOwner(owner); + // Get light-token interface signatures + const result = await connection.getSignaturesForOwnerInterface(owner); - if (signatures.items.length === 0) { + if (!result.signatures || result.signatures.length === 0) { return { count: 0, transactions: [], }; } - // Limit results - const limitedSignatures = signatures.items.slice(0, limit); + const limitedSignatures = result.signatures.slice(0, limit); - // Get detailed info if requested - if (includeDetails && limitedSignatures.length > 0) { - const transactions = await Promise.all( - limitedSignatures.map(async (sig) => { - const txInfo = await connection.getTransactionWithCompressionInfo(sig.signature); - - return { - signature: sig.signature, - slot: sig.slot, - blockTime: sig.blockTime, - timestamp: new Date(sig.blockTime * 1000).toISOString(), - compressionInfo: txInfo?.compressionInfo ? { - closedAccounts: txInfo.compressionInfo.closedAccounts.length, - openedAccounts: txInfo.compressionInfo.openedAccounts.length, - } : null, - }; - }) - ); - - return { - count: signatures.items.length, - transactions, - }; - } - - // Return basic signature info const transactions = limitedSignatures.map((sig) => ({ signature: sig.signature, slot: sig.slot, - blockTime: sig.blockTime, - timestamp: new Date(sig.blockTime * 1000).toISOString(), + blockTime: sig.blockTime ?? 0, + timestamp: sig.blockTime ? new Date(sig.blockTime * 1000).toISOString() : '', })); return { - count: signatures.items.length, + count: result.signatures.length, transactions, }; }; diff --git a/snippets/code-snippets/privy/transaction-history/react.mdx b/snippets/code-snippets/privy/transaction-history/react.mdx index b7fe5611..d76d7a57 100644 --- a/snippets/code-snippets/privy/transaction-history/react.mdx +++ b/snippets/code-snippets/privy/transaction-history/react.mdx @@ -1,96 +1 @@ -```typescript -import { useState, useCallback } from 'react'; -import { PublicKey } from '@solana/web3.js'; -import { createRpc } from '@lightprotocol/stateless.js'; - -export interface TransactionCompressionInfo { - closedAccounts: number; - openedAccounts: number; -} - -export interface Transaction { - signature: string; - slot: number; - blockTime: number; - timestamp: string; - compressionInfo?: TransactionCompressionInfo | null; -} - -export function useTransactionHistory() { - const [transactions, setTransactions] = useState([]); - const [isLoading, setIsLoading] = useState(false); - const [error, setError] = useState(null); - - const fetchTransactionHistory = useCallback( - async ( - ownerAddress: string, - limit: number = 10, - includeDetails: boolean = false - ) => { - if (!ownerAddress) { - setTransactions([]); - return; - } - - setIsLoading(true); - setError(null); - - try { - const rpc = createRpc(import.meta.env.VITE_HELIUS_RPC_URL); - const owner = new PublicKey(ownerAddress); - - const signatures = await rpc.getCompressionSignaturesForTokenOwner(owner); - - if (signatures.items.length === 0) { - setTransactions([]); - return; - } - - const limitedSignatures = signatures.items.slice(0, limit); - - if (includeDetails && limitedSignatures.length > 0) { - const transactionsWithDetails = await Promise.all( - limitedSignatures.map(async (sig) => { - const txInfo = await rpc.getTransactionWithCompressionInfo(sig.signature); - - return { - signature: sig.signature, - slot: sig.slot, - blockTime: sig.blockTime, - timestamp: new Date(sig.blockTime * 1000).toISOString(), - compressionInfo: txInfo?.compressionInfo - ? { - closedAccounts: txInfo.compressionInfo.closedAccounts.length, - openedAccounts: txInfo.compressionInfo.openedAccounts.length, - } - : null, - }; - }) - ); - - setTransactions(transactionsWithDetails); - return; - } - - const basicTransactions = limitedSignatures.map((sig) => ({ - signature: sig.signature, - slot: sig.slot, - blockTime: sig.blockTime, - timestamp: new Date(sig.blockTime * 1000).toISOString(), - })); - - setTransactions(basicTransactions); - } catch (err) { - const message = err instanceof Error ? err.message : String(err); - setError(message); - setTransactions([]); - } finally { - setIsLoading(false); - } - }, - [] - ); - - return { transactions, isLoading, error, fetchTransactionHistory }; -} -``` +React example coming soon. diff --git a/snippets/code-snippets/privy/transfer/nodejs.mdx b/snippets/code-snippets/privy/transfer/nodejs.mdx index 0d4134b8..76cb051d 100644 --- a/snippets/code-snippets/privy/transfer/nodejs.mdx +++ b/snippets/code-snippets/privy/transfer/nodejs.mdx @@ -1,16 +1,18 @@ ```typescript import 'dotenv/config'; import {PrivyClient} from '@privy-io/node'; -import {createRpc, bn} from '@lightprotocol/stateless.js'; -import {PublicKey, Transaction, ComputeBudgetProgram} from '@solana/web3.js'; -import {LightTokenProgram, selectMinCompressedTokenAccountsForTransfer} from '@lightprotocol/compressed-token'; +import {createRpc} from '@lightprotocol/stateless.js'; +import {PublicKey, Transaction} from '@solana/web3.js'; +import { + createTransferInterfaceInstructions, +} from '@lightprotocol/compressed-token/unified'; -const transferCompressedTokens = async ( +const transferLightTokens = async ( fromAddress: string, toAddress: string, tokenMintAddress: string, amount: number, - decimals: number = 6 + decimals: number = 9, ) => { const connection = createRpc(process.env.HELIUS_RPC_URL!); @@ -19,69 +21,46 @@ const transferCompressedTokens = async ( appSecret: process.env.PRIVY_APP_SECRET!, }); - // Create public key objects const fromPubkey = new PublicKey(fromAddress); const toPubkey = new PublicKey(toAddress); const mintPubkey = new PublicKey(tokenMintAddress); - const tokenAmount = bn(amount * Math.pow(10, decimals)); + const tokenAmount = Math.floor(amount * Math.pow(10, decimals)); - // Get compressed token accounts (filter out null items from indexer) - const accounts = await connection.getCompressedTokenAccountsByOwner(fromPubkey, {mint: mintPubkey}); - const validItems = (accounts.items || []).filter((item): item is NonNullable => item !== null); - if (validItems.length === 0) { - throw new Error('No compressed token accounts found'); - } - - // Select minimum accounts needed for transfer - const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(validItems, tokenAmount); - if (inputAccounts.length === 0) { - throw new Error('Insufficient balance'); - } - - // Get validity proof to prove compressed token accounts exist in state tree. - const proof = await connection.getValidityProof(inputAccounts.map(account => bn(account.compressedAccount.hash))); + // Returns TransactionInstruction[][]. + // Each inner array is one transaction. + // Almost always returns just one. + const instructions = await createTransferInterfaceInstructions( + connection, fromPubkey, mintPubkey, tokenAmount, fromPubkey, toPubkey, + ); - // Create transfer instruction - const instruction = await LightTokenProgram.transfer({ - payer: fromPubkey, - inputCompressedTokenAccounts: inputAccounts, - toAddress: toPubkey, - amount: tokenAmount, - recentInputStateRootIndices: proof.rootIndices, - recentValidityProof: proof.compressedProof, - }); + // Sign and send each batch via Privy + const walletId = process.env.TREASURY_WALLET_ID!; + const authorizationKey = process.env.TREASURY_AUTHORIZATION_KEY!; + const signatures: string[] = []; - // Create transaction - const transaction = new Transaction(); - transaction.add(ComputeBudgetProgram.setComputeUnitLimit({units: 300_000})); - transaction.add(instruction); + for (const ixs of instructions) { + const tx = new Transaction().add(...ixs); + const {blockhash} = await connection.getLatestBlockhash(); + tx.recentBlockhash = blockhash; + tx.feePayer = fromPubkey; - // Get recent blockhash - const {blockhash} = await connection.getLatestBlockhash(); - transaction.recentBlockhash = blockhash; - transaction.feePayer = fromPubkey; + const {signed_transaction} = await privy.wallets().solana().signTransaction( + walletId, { + transaction: tx.serialize({requireAllSignatures: false}), + authorization_context: {authorization_private_keys: [authorizationKey]}, + }, + ) as any; - // Sign with Privy - const signResult = await privy.wallets().solana().signTransaction(process.env.TREASURY_WALLET_ID!, { - transaction: transaction.serialize({requireAllSignatures: false}), - authorization_context: { - authorization_private_keys: [process.env.TREASURY_AUTHORIZATION_KEY!] - } - }); - const signedTx = (signResult as any).signed_transaction || signResult.signedTransaction; - if (!signedTx) { - throw new Error('Privy returned invalid response: ' + JSON.stringify(signResult)); + const sig = await connection.sendRawTransaction( + Buffer.from(signed_transaction, 'base64'), + {skipPreflight: false, preflightCommitment: 'confirmed'}, + ); + await connection.confirmTransaction(sig, 'confirmed'); + signatures.push(sig); } - const signedTransaction = Buffer.from(signedTx, 'base64'); - - // Send transaction - const signature = await connection.sendRawTransaction(signedTransaction, { - skipPreflight: false, - preflightCommitment: 'confirmed' - }); - await connection.confirmTransaction(signature, 'confirmed'); - return signature; + return signatures[signatures.length - 1]; }; -export default transferCompressedTokens;``` +export default transferLightTokens; +``` diff --git a/snippets/code-snippets/privy/transfer/react.mdx b/snippets/code-snippets/privy/transfer/react.mdx index c532013b..d76d7a57 100644 --- a/snippets/code-snippets/privy/transfer/react.mdx +++ b/snippets/code-snippets/privy/transfer/react.mdx @@ -1,105 +1 @@ -```typescript -import { useState } from 'react'; -import { PublicKey, Transaction, ComputeBudgetProgram } from '@solana/web3.js'; -import { LightTokenProgram, selectMinCompressedTokenAccountsForTransfer } from '@lightprotocol/compressed-token'; -import { bn, createRpc } from '@lightprotocol/stateless.js'; -import type { ConnectedStandardSolanaWallet } from '@privy-io/js-sdk-core'; -import type { SignTransactionResult } from '@privy-io/react-auth/solana'; - -export interface TransferParams { - ownerPublicKey: string; - mint: string; - toAddress: string; - amount: number; - decimals?: number; -} - -export interface TransferArgs { - params: TransferParams; - wallet: ConnectedStandardSolanaWallet; - signTransaction: (args: { - transaction: Buffer; - wallet: ConnectedStandardSolanaWallet; - chain: string; - }) => Promise; -} - -export function useTransfer() { - const [isLoading, setIsLoading] = useState(false); - - const transfer = async (args: TransferArgs): Promise => { - setIsLoading(true); - - try { - const { params, wallet, signTransaction } = args; - const { ownerPublicKey, mint, toAddress, amount, decimals = 6 } = params; - - // Create RPC connection - const rpc = createRpc(import.meta.env.VITE_HELIUS_RPC_URL); - - const owner = new PublicKey(ownerPublicKey); - const mintPubkey = new PublicKey(mint); - const recipient = new PublicKey(toAddress); - const tokenAmount = bn(Math.floor(amount * Math.pow(10, decimals))); - - // Get compressed token accounts - const accounts = await rpc.getCompressedTokenAccountsByOwner(owner, { mint: mintPubkey }); - if (!accounts.items || accounts.items.length === 0) { - throw new Error('No compressed token accounts found'); - } - - // Select minimum accounts needed - const [inputAccounts] = selectMinCompressedTokenAccountsForTransfer(accounts.items, tokenAmount); - if (inputAccounts.length === 0) { - throw new Error('Insufficient balance'); - } - - // Get validity proof - const proof = await rpc.getValidityProof( - inputAccounts.map((account) => bn(account.compressedAccount.hash)) - ); - - // Build transfer instruction - const transferIx = await LightTokenProgram.transfer({ - payer: owner, - inputCompressedTokenAccounts: inputAccounts, - toAddress: recipient, - amount: tokenAmount, - recentInputStateRootIndices: proof.rootIndices, - recentValidityProof: proof.compressedProof, - }); - - // Build transaction - const { blockhash } = await rpc.getLatestBlockhash(); - const transaction = new Transaction(); - transaction.add(ComputeBudgetProgram.setComputeUnitLimit({ units: 300_000 })); - transaction.add(transferIx); - transaction.recentBlockhash = blockhash; - transaction.feePayer = owner; - - // Serialize unsigned transaction - const unsignedTxBuffer = transaction.serialize({ requireAllSignatures: false }); - - // Sign with Privy - const signedTx = await signTransaction({ - transaction: unsignedTxBuffer, - wallet, - chain: 'solana:devnet', - }); - - // Send transaction - const signedTxBuffer = Buffer.from(signedTx.signedTransaction); - const signature = await rpc.sendRawTransaction(signedTxBuffer, { - skipPreflight: false, - preflightCommitment: 'confirmed', - }); - - return signature; - } finally { - setIsLoading(false); - } - }; - - return { transfer, isLoading }; -} -``` +React example coming soon. diff --git a/snippets/code-snippets/privy/unwrap/nodejs.mdx b/snippets/code-snippets/privy/unwrap/nodejs.mdx new file mode 100644 index 00000000..dfaba54d --- /dev/null +++ b/snippets/code-snippets/privy/unwrap/nodejs.mdx @@ -0,0 +1,68 @@ +```typescript +import 'dotenv/config'; +import {PrivyClient} from '@privy-io/node'; +import {createRpc} from '@lightprotocol/stateless.js'; +import {PublicKey, Transaction} from '@solana/web3.js'; +import {getAssociatedTokenAddressSync} from '@solana/spl-token'; +import { + createUnwrapInstructions, +} from '@lightprotocol/compressed-token/unified'; + +const unwrapTokens = async ( + fromAddress: string, + tokenMintAddress: string, + amount: number, + decimals: number = 9, +) => { + const connection = createRpc(process.env.HELIUS_RPC_URL!); + + const privy = new PrivyClient({ + appId: process.env.PRIVY_APP_ID!, + appSecret: process.env.PRIVY_APP_SECRET!, + }); + + const fromPubkey = new PublicKey(fromAddress); + const mintPubkey = new PublicKey(tokenMintAddress); + const tokenAmount = BigInt(Math.floor(amount * Math.pow(10, decimals))); + + // Destination: SPL/T22 associated token account + const splAta = getAssociatedTokenAddressSync(mintPubkey, fromPubkey); + + // Returns TransactionInstruction[][]. + // Each inner array is one transaction. + // Handles loading + unwrapping together. + const instructions = await createUnwrapInstructions( + connection, splAta, fromPubkey, mintPubkey, tokenAmount, fromPubkey, + ); + + // Sign and send each batch via Privy + const walletId = process.env.TREASURY_WALLET_ID!; + const authorizationKey = process.env.TREASURY_AUTHORIZATION_KEY!; + const signatures: string[] = []; + + for (const ixs of instructions) { + const tx = new Transaction().add(...ixs); + const {blockhash} = await connection.getLatestBlockhash(); + tx.recentBlockhash = blockhash; + tx.feePayer = fromPubkey; + + const {signed_transaction} = await privy.wallets().solana().signTransaction( + walletId, { + transaction: tx.serialize({requireAllSignatures: false}), + authorization_context: {authorization_private_keys: [authorizationKey]}, + }, + ) as any; + + const sig = await connection.sendRawTransaction( + Buffer.from(signed_transaction, 'base64'), + {skipPreflight: false, preflightCommitment: 'confirmed'}, + ); + await connection.confirmTransaction(sig, 'confirmed'); + signatures.push(sig); + } + + return signatures[signatures.length - 1]; +}; + +export default unwrapTokens; +``` diff --git a/snippets/code-snippets/privy/unwrap/react.mdx b/snippets/code-snippets/privy/unwrap/react.mdx new file mode 100644 index 00000000..d76d7a57 --- /dev/null +++ b/snippets/code-snippets/privy/unwrap/react.mdx @@ -0,0 +1 @@ +React example coming soon. diff --git a/snippets/code-snippets/privy/wrap/nodejs.mdx b/snippets/code-snippets/privy/wrap/nodejs.mdx new file mode 100644 index 00000000..61f1b1e2 --- /dev/null +++ b/snippets/code-snippets/privy/wrap/nodejs.mdx @@ -0,0 +1,86 @@ +```typescript +import 'dotenv/config'; +import {PrivyClient} from '@privy-io/node'; +import {createRpc, CTOKEN_PROGRAM_ID} from '@lightprotocol/stateless.js'; +import {PublicKey, Transaction, ComputeBudgetProgram} from '@solana/web3.js'; +import {getAssociatedTokenAddressSync, getAccount} from '@solana/spl-token'; +import {getSplInterfaceInfos} from '@lightprotocol/compressed-token'; +import { + createWrapInstruction, + getAssociatedTokenAddressInterface, + createAssociatedTokenAccountInterfaceIdempotentInstruction, +} from '@lightprotocol/compressed-token/unified'; + +const wrapTokens = async ( + fromAddress: string, + tokenMintAddress: string, + amount: number, + decimals: number = 9, +) => { + const connection = createRpc(process.env.HELIUS_RPC_URL!); + + const privy = new PrivyClient({ + appId: process.env.PRIVY_APP_ID!, + appSecret: process.env.PRIVY_APP_SECRET!, + }); + + const fromPubkey = new PublicKey(fromAddress); + const mintPubkey = new PublicKey(tokenMintAddress); + const tokenAmount = BigInt(Math.floor(amount * Math.pow(10, decimals))); + + // Get SPL interface info — determines whether mint uses SPL or T22 + const splInterfaceInfos = await getSplInterfaceInfos(connection, mintPubkey); + const splInterfaceInfo = splInterfaceInfos.find( + (info) => info.isInitialized, + ); + if (!splInterfaceInfo) throw new Error('No SPL interface found for this mint'); + + // Derive source associated token account using the mint's token program (SPL or T22) + const {tokenProgram} = splInterfaceInfo; + const splAta = getAssociatedTokenAddressSync(mintPubkey, fromPubkey, false, tokenProgram); + const ataAccount = await getAccount(connection, splAta, undefined, tokenProgram); + if (ataAccount.amount < BigInt(tokenAmount)) { + throw new Error('Insufficient SPL balance'); + } + + // Derive light-token associated token account + const lightTokenAta = getAssociatedTokenAddressInterface(mintPubkey, fromPubkey); + + // Build instructions + const tx = new Transaction().add( + ComputeBudgetProgram.setComputeUnitLimit({units: 200_000}), + createAssociatedTokenAccountInterfaceIdempotentInstruction( + fromPubkey, lightTokenAta, fromPubkey, mintPubkey, CTOKEN_PROGRAM_ID, + ), + createWrapInstruction( + splAta, lightTokenAta, fromPubkey, mintPubkey, + tokenAmount, splInterfaceInfo, decimals, fromPubkey, + ), + ); + + // Sign and send via Privy + const {blockhash} = await connection.getLatestBlockhash(); + tx.recentBlockhash = blockhash; + tx.feePayer = fromPubkey; + + const walletId = process.env.TREASURY_WALLET_ID!; + const authorizationKey = process.env.TREASURY_AUTHORIZATION_KEY!; + + const {signed_transaction} = await privy.wallets().solana().signTransaction( + walletId, { + transaction: tx.serialize({requireAllSignatures: false}), + authorization_context: {authorization_private_keys: [authorizationKey]}, + }, + ) as any; + + const signature = await connection.sendRawTransaction( + Buffer.from(signed_transaction, 'base64'), + {skipPreflight: false, preflightCommitment: 'confirmed'}, + ); + await connection.confirmTransaction(signature, 'confirmed'); + + return signature; +}; + +export default wrapTokens; +``` diff --git a/snippets/code-snippets/privy/wrap/react.mdx b/snippets/code-snippets/privy/wrap/react.mdx new file mode 100644 index 00000000..d76d7a57 --- /dev/null +++ b/snippets/code-snippets/privy/wrap/react.mdx @@ -0,0 +1 @@ +React example coming soon. diff --git a/snippets/overview-tables/compressed-pdas-guides-table.mdx b/snippets/overview-tables/compressed-pdas-guides-table.mdx index 8ee1299f..63763552 100644 --- a/snippets/overview-tables/compressed-pdas-guides-table.mdx +++ b/snippets/overview-tables/compressed-pdas-guides-table.mdx @@ -12,37 +12,37 @@ - Create + Create Initialize compressed PDAs in your program - Update + Update Modify state in compressed accounts - Close + Close Reclaim lamports from compressed accounts - Reinitialize + Reinitialize Reset and reuse compressed accounts - Burn + Burn Permanently delete compressed accounts - Nullifier PDAs + Nullifier PDAs Prevent replay attacks with one-time use accounts diff --git a/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx b/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx index 48166ba4..88ccd3dc 100644 --- a/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx +++ b/snippets/overview-tables/compressed-tokens-advanced-guides-table.mdx @@ -1,4 +1,4 @@ | Guide | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | | [Create an Airdrop without Claim](/compressed-tokens/airdrop) | ZK Compression is the most efficient way to distribute SPL tokens. Distribute via Webapp or customize with claim. | -| [Privy Guide](/compressed-tokens/for-privy) | Integrate compressed tokens with Privy embedded wallets for rent-free token accounts | +| [Privy Guide](/light-token/toolkits/for-privy) | Integrate light-tokens with Privy embedded wallets for rent-free token accounts | diff --git a/snippets/overview-tables/sdk-reference.mdx b/snippets/overview-tables/sdk-reference.mdx index 09d94598..000c6f38 100644 --- a/snippets/overview-tables/sdk-reference.mdx +++ b/snippets/overview-tables/sdk-reference.mdx @@ -21,6 +21,16 @@ Rust token operations for Light Token. + + TypeScript SDK for creating nullifier PDAs to prevent duplicate actions. + + + Rust SDK for creating nullifier PDAs to prevent duplicate actions. + ### Program diff --git a/snippets/setup/agent-skill-defi-program.mdx b/snippets/setup/agent-skill-defi-program.mdx new file mode 100644 index 00000000..1d2994cc --- /dev/null +++ b/snippets/setup/agent-skill-defi-program.mdx @@ -0,0 +1,9 @@ +import InstallAgentSkills from "/snippets/setup/install-agent-skills.mdx"; + + + +Use the [defi-program](https://github.com/Lightprotocol/skills/tree/main/skills/defi-program) agent skill to build rent-free DeFi programs: + + + + diff --git a/snippets/setup/agent-skill-defi-router.mdx b/snippets/setup/agent-skill-defi-router.mdx new file mode 100644 index 00000000..83171a18 --- /dev/null +++ b/snippets/setup/agent-skill-defi-router.mdx @@ -0,0 +1,9 @@ +import InstallAgentSkills from "/snippets/setup/install-agent-skills.mdx"; + + + +Use the [defi-router](https://github.com/Lightprotocol/skills/tree/main/skills/defi-router) agent skill to integrate rent-free markets into your router: + + + + diff --git a/snippets/setup/agent-skill-generic.mdx b/snippets/setup/agent-skill-generic.mdx new file mode 100644 index 00000000..df59651e --- /dev/null +++ b/snippets/setup/agent-skill-generic.mdx @@ -0,0 +1,11 @@ + + +Install the [agent skill](https://zkcompression.com/skill.md): + +```bash +npx skills add https://zkcompression.com +``` + +See the [AI tools guide](/ai-tools/guide) for dedicated skills. + + diff --git a/snippets/setup/agent-skill-payments.mdx b/snippets/setup/agent-skill-payments.mdx new file mode 100644 index 00000000..80e5711f --- /dev/null +++ b/snippets/setup/agent-skill-payments.mdx @@ -0,0 +1,9 @@ +import InstallAgentSkills from "/snippets/setup/install-agent-skills.mdx"; + + + +Use the [payments-and-wallets](https://github.com/Lightprotocol/skills/tree/main/skills/payments-and-wallets) agent skill to add light-token payment support to your project: + + + + diff --git a/snippets/setup/agent-skill-streaming.mdx b/snippets/setup/agent-skill-streaming.mdx new file mode 100644 index 00000000..d3bb9e7b --- /dev/null +++ b/snippets/setup/agent-skill-streaming.mdx @@ -0,0 +1,9 @@ +import InstallAgentSkills from "/snippets/setup/install-agent-skills.mdx"; + + + +Use the [data-streaming](https://github.com/Lightprotocol/skills/tree/main/skills/data-streaming) agent skill to add Laserstream support to your project: + + + + diff --git a/snippets/setup/install-agent-skills.mdx b/snippets/setup/install-agent-skills.mdx new file mode 100644 index 00000000..a56f41ed --- /dev/null +++ b/snippets/setup/install-agent-skills.mdx @@ -0,0 +1,27 @@ +For orchestration, install the [agent skill](https://zkcompression.com/skill.md): + +```bash +npx skills add https://zkcompression.com +``` + + + +Add the marketplace and install: + +``` +/plugin marketplace add Lightprotocol/skills +/plugin install solana-rent-free-dev +``` + + +1. Open Settings (**Cmd+Shift+J** / **Ctrl+Shift+J**) +2. Navigate to **Rules & Commands** → **Project Rules** → **Add Rule** → **Remote Rule (GitHub)** +3. Enter: `https://github.com/Lightprotocol/skills.git` + + + +``` +npx skills add Lightprotocol/skills +``` + + diff --git a/snippets/setup/register-spl-mint.mdx b/snippets/setup/register-spl-mint.mdx new file mode 100644 index 00000000..f6ab4281 --- /dev/null +++ b/snippets/setup/register-spl-mint.mdx @@ -0,0 +1,68 @@ +### One-time: Register an Existing SPL Mint + +For existing SPL mints (e.g. USDC), register the SPL interface once. This creates the omnibus PDA that holds SPL tokens when wrapped to light-token. + + +Find a full code example [here](https://github.com/Lightprotocol/examples-light-token/blob/main/toolkits/payments-and-wallets/register-spl-mint.ts). + + +Check if the interface already exists: + +```typescript +import { getSplInterfaceInfos } from "@lightprotocol/compressed-token"; + +try { + const infos = await getSplInterfaceInfos(rpc, mint); + const exists = infos.some((i) => i.isInitialized); + console.log("Interface exists:", exists); +} catch { + console.log("No interface registered for this mint."); +} +``` + +Register: + + + + +```typescript +import { Transaction, sendAndConfirmTransaction } from "@solana/web3.js"; +import { LightTokenProgram } from "@lightprotocol/compressed-token"; +import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; + +const ix = await LightTokenProgram.createSplInterface({ + feePayer: payer.publicKey, + mint, + tokenProgramId: TOKEN_PROGRAM_ID, +}); + +const tx = new Transaction().add(ix); +await sendAndConfirmTransaction(rpc, tx, [payer]); +``` + + + + +```typescript +import { createSplInterface } from "@lightprotocol/compressed-token"; + +await createSplInterface(rpc, payer, mint); +``` + + + + + + +Use `createMintInterface` with `TOKEN_PROGRAM_ID` to create a new SPL mint and register the interface in one transaction: + +```typescript +import { createMintInterface } from "@lightprotocol/compressed-token/unified"; +import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; + +const { mint } = await createMintInterface( + rpc, payer, payer, null, 9, undefined, undefined, TOKEN_PROGRAM_ID +); +``` + + \ No newline at end of file diff --git a/use-agent.skill b/use-agent.skill new file mode 100644 index 0000000000000000000000000000000000000000..528f89fb1b5ac0b7b10025b15b235f4898f293cd GIT binary patch literal 940 zcmWIWW@Zs#U|`^2a9`se68&IrPahw>+?3Fe z+kVo90=3`6dotu3)EvKj5?aZh*&(2{rK2Ha<*EZWWrf7o@BO5D;QsfXa?fr0ahbN$ zi_gvZSYZ?9XKu4prgF{oHFyEEyROTg^ICVUHPt*>tGQtHgXAR- zblt6Z_L%-Tljw3Q^S9LH4j*O#Uadk4slXHGJm0MgJ)@l|@BYO3`hy24?tOKq@6Km7 z68y34U*~JijvUJ)P2H;wM9t{8;*)xF&2Luk3dYdAZu$pR@R-|@R5A+@U9%V;+Jcnk@@S51mw?p?9W4^IVKxFPLx%LW` z!jtS}yFcl-9=pwPao#v zq6=Ovj$l_$y0 z@YejqOp&Y4Idxrs*uDqkKzs=kfGB;n4gPptHC52D{{Sxn~c(Zl80Qn)mh81Ify_$K@~U6(`GGZr}aw z$(imPIlXNXPMxpKst)|wKPP(cq#vIyG^}}ATFLtKsXNDK%P8I*fxVmqCWxaY==Lc(`XFz%7 z(O#>^B`eLh3Y?h6f5kq)n~_O`8F#({W-Tz-(g>n3b6J2lD;r3L5eOZCbQmyCGB5xD D2MDai literal 0 HcmV?d00001 diff --git a/zk/overview.mdx b/zk/overview.mdx index 781e76dd..4ba145ef 100644 --- a/zk/overview.mdx +++ b/zk/overview.mdx @@ -120,7 +120,7 @@ ZK applications on Solana can use existing state Merkle trees to store state in | 100-byte PDA | ~1,600,000 lamports | 15,000 lamports | -Your circuit must include compressed accounts. Find [guides to compressed accounts in the documentation](/compressed-pdas/overview) and the [full example with zk implementation here](https://github.com/Lightprotocol/program-examples/blob/99d260f9f356743b8fe3501c684f7926930d6079/zk-id/circuits/compressed_account.circom). +Your circuit must include compressed accounts. Find [guides to compressed accounts in the documentation](/pda/compressed-pdas/overview) and the [full example with zk implementation here](https://github.com/Lightprotocol/program-examples/blob/99d260f9f356743b8fe3501c684f7926930d6079/zk-id/circuits/compressed_account.circom). ## Get Started & Examples From c6854295874c5a0221b923c21f691ca576b08fbf Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Sun, 15 Feb 2026 22:02:49 +0000 Subject: [PATCH 19/27] reordeing --- light-token/cookbook/approve-revoke.mdx | 4 ++-- light-token/cookbook/burn.mdx | 4 ++-- light-token/cookbook/close-token-account.mdx | 4 ++-- light-token/cookbook/freeze-thaw.mdx | 4 ++-- light-token/cookbook/load-ata.mdx | 4 ++-- light-token/cookbook/mint-to.mdx | 4 ++-- light-token/cookbook/transfer-checked.mdx | 4 ++-- light-token/cookbook/transfer-interface.mdx | 4 ++-- light-token/cookbook/wrap-unwrap.mdx | 4 ++-- light-token/examples/client.mdx | 4 +++- light-token/examples/program.mdx | 4 +++- light-token/quickstart.mdx | 4 +++- pda/light-pda/overview.mdx | 4 +++- snippets/setup/install-agent-skills.mdx | 12 ++++++------ 14 files changed, 36 insertions(+), 28 deletions(-) diff --git a/light-token/cookbook/approve-revoke.mdx b/light-token/cookbook/approve-revoke.mdx index efa31db0..b5c1277a 100644 --- a/light-token/cookbook/approve-revoke.mdx +++ b/light-token/cookbook/approve-revoke.mdx @@ -36,6 +36,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 2. Revoke removes all delegate permissions from a Light Token account. 3. Only the token account owner can approve or revoke delegates. + + @@ -300,5 +302,3 @@ revoke_cpi.invoke_signed(&[signer_seeds])?; href="/light-token/welcome" horizontal /> - - diff --git a/light-token/cookbook/burn.mdx b/light-token/cookbook/burn.mdx index 552073fa..804ddf44 100644 --- a/light-token/cookbook/burn.mdx +++ b/light-token/cookbook/burn.mdx @@ -23,6 +23,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 2. Burned tokens are removed from circulation and decreases the supply tracked on the mint account. 3. Only the token account owner (or approved delegate) can burn tokens. + + @@ -136,5 +138,3 @@ BurnCpi { href="/light-token/cookbook/freeze-thaw" horizontal /> - - diff --git a/light-token/cookbook/close-token-account.mdx b/light-token/cookbook/close-token-account.mdx index ed0dbca0..4a560c10 100644 --- a/light-token/cookbook/close-token-account.mdx +++ b/light-token/cookbook/close-token-account.mdx @@ -28,6 +28,8 @@ closes the account and preserves the balance as compressed token account when th The account is reinstated in flight with the same state the next time it is accessed. + + @@ -145,5 +147,3 @@ CloseAccountCpi { href="/light-token/welcome" horizontal /> - - diff --git a/light-token/cookbook/freeze-thaw.mdx b/light-token/cookbook/freeze-thaw.mdx index feb98d18..2c3491f7 100644 --- a/light-token/cookbook/freeze-thaw.mdx +++ b/light-token/cookbook/freeze-thaw.mdx @@ -27,6 +27,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 4. Only the freeze authority (set at mint creation) can freeze or thaw accounts. 5. If the freeze authority is revoked (set to null) on the mint account, tokens can never be frozen. + + @@ -226,5 +228,3 @@ ThawCpi { href="/light-token/cookbook/approve-revoke" horizontal /> - - diff --git a/light-token/cookbook/load-ata.mdx b/light-token/cookbook/load-ata.mdx index a0da7dea..73fd2f19 100644 --- a/light-token/cookbook/load-ata.mdx +++ b/light-token/cookbook/load-ata.mdx @@ -23,6 +23,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; Find the source code [here](https://github.com/Lightprotocol/light-protocol/blob/main/js/compressed-token/src/v3/actions/load-ata.ts). + + ### Unify Tokens to Light-ATA Balance @@ -40,5 +42,3 @@ Find the source code [here](https://github.com/Lightprotocol/light-protocol/blob - - diff --git a/light-token/cookbook/mint-to.mdx b/light-token/cookbook/mint-to.mdx index 0f866cf9..4b88748c 100644 --- a/light-token/cookbook/mint-to.mdx +++ b/light-token/cookbook/mint-to.mdx @@ -30,6 +30,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 1. Mint To creates new tokens of a mint and deposits them to a specified token account. 2. Before we can mint any tokens, we need an initialized mint account (SPL, Token 2022 or Light) for which we hold the mint authority. + + @@ -195,5 +197,3 @@ MintToCpi { href="/light-token/cookbook/transfer-interface" horizontal > - - diff --git a/light-token/cookbook/transfer-checked.mdx b/light-token/cookbook/transfer-checked.mdx index 5df57024..141c4263 100644 --- a/light-token/cookbook/transfer-checked.mdx +++ b/light-token/cookbook/transfer-checked.mdx @@ -17,6 +17,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; 2. Use for Light→Light transfers when you need decimal verification. 3. For transfers involving SPL or Token 2022 accounts, use [Transfer Interface](/light-token/cookbook/transfer-interface) instead. + + @@ -129,5 +131,3 @@ TransferCheckedCpi { href="/light-token/cookbook/close-token-account" horizontal /> - - diff --git a/light-token/cookbook/transfer-interface.mdx b/light-token/cookbook/transfer-interface.mdx index 3deb4903..bcc50c11 100644 --- a/light-token/cookbook/transfer-interface.mdx +++ b/light-token/cookbook/transfer-interface.mdx @@ -57,6 +57,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; + + @@ -243,5 +245,3 @@ Uses the `#[light_account(init, associated_token::...)]` macro to create the des href="/light-token/cookbook/transfer-checked" horizontal /> - - diff --git a/light-token/cookbook/wrap-unwrap.mdx b/light-token/cookbook/wrap-unwrap.mdx index c4e1b8c6..aa39c5d0 100644 --- a/light-token/cookbook/wrap-unwrap.mdx +++ b/light-token/cookbook/wrap-unwrap.mdx @@ -27,6 +27,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; [unwrap.ts](https://github.com/Lightprotocol/light-protocol/blob/0c4e2417b2df2d564721b89e18d1aad3665120e7/js/compressed-token/src/v3/actions/unwrap.ts) + + @@ -134,5 +136,3 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; - - diff --git a/light-token/examples/client.mdx b/light-token/examples/client.mdx index 56e79f08..dd935794 100644 --- a/light-token/examples/client.mdx +++ b/light-token/examples/client.mdx @@ -9,6 +9,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; Find all examples on Github: [examples-light-token](https://github.com/Lightprotocol/examples-light-token) + + - + diff --git a/light-token/examples/program.mdx b/light-token/examples/program.mdx index 88b0a9f6..2cc58ce0 100644 --- a/light-token/examples/program.mdx +++ b/light-token/examples/program.mdx @@ -9,6 +9,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; Find all examples on Github: [examples-light-token](https://github.com/Lightprotocol/examples-light-token) + + - + diff --git a/light-token/quickstart.mdx b/light-token/quickstart.mdx index cdbb008e..af9fdc75 100644 --- a/light-token/quickstart.mdx +++ b/light-token/quickstart.mdx @@ -9,6 +9,8 @@ import FullSetup from "/snippets/setup/full-setup.mdx"; import MintToAction from "/snippets/code-snippets/light-token/mint-to/action.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; + + @@ -46,4 +48,4 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; - + diff --git a/pda/light-pda/overview.mdx b/pda/light-pda/overview.mdx index a830ae94..4eb1a1e6 100644 --- a/pda/light-pda/overview.mdx +++ b/pda/light-pda/overview.mdx @@ -23,6 +23,8 @@ Audit overhead is minimal as your program logic is mostly untouched. The rest is --- + + ## Step 1: Dependencies ```toml @@ -192,4 +194,4 @@ API is in Beta and subject to change. Questions or need hands-on support? [Telegram](https://t.me/swen_light) | [email](mailto:support@lightprotocol.com) | [Discord](https://discord.com/invite/7cJ8BhAXhu) - + diff --git a/snippets/setup/install-agent-skills.mdx b/snippets/setup/install-agent-skills.mdx index a56f41ed..ffa18e7d 100644 --- a/snippets/setup/install-agent-skills.mdx +++ b/snippets/setup/install-agent-skills.mdx @@ -1,9 +1,3 @@ -For orchestration, install the [agent skill](https://zkcompression.com/skill.md): - -```bash -npx skills add https://zkcompression.com -``` - Add the marketplace and install: @@ -25,3 +19,9 @@ npx skills add Lightprotocol/skills ``` + +For orchestration, install the [general skill](https://zkcompression.com/skill.md): + +```bash +npx skills add https://zkcompression.com +``` \ No newline at end of file From 34daf1508484ff9e317efe54324b6192a152ba18 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Sun, 15 Feb 2026 23:32:06 +0000 Subject: [PATCH 20/27] prompts --- ai-tools/guide.mdx | 22 ++++--- ai-tools/prompts.mdx | 35 ++++++++++++ compressed-tokens/airdrop.mdx | 3 + compressed-tokens/overview.mdx | 3 + docs.json | 3 +- light-token/cookbook/approve-revoke.mdx | 8 +++ light-token/cookbook/create-ata.mdx | 8 +++ light-token/cookbook/create-mint.mdx | 8 +++ light-token/cookbook/mint-to.mdx | 8 +++ light-token/cookbook/transfer-interface.mdx | 8 +++ light-token/cookbook/wrap-unwrap.mdx | 8 +++ snippets/ai-prompts/template.mdx | 55 ++++++++++++++++++ .../ai-prompts/ts-cookbook/approve-revoke.mdx | 54 ++++++++++++++++++ .../ai-prompts/ts-cookbook/create-ata.mdx | 54 ++++++++++++++++++ .../ai-prompts/ts-cookbook/create-mint.mdx | 54 ++++++++++++++++++ snippets/ai-prompts/ts-cookbook/mint-to.mdx | 54 ++++++++++++++++++ .../ts-cookbook/transfer-interface.mdx | 57 +++++++++++++++++++ .../ai-prompts/ts-cookbook/wrap-unwrap.mdx | 55 ++++++++++++++++++ snippets/setup/agent-skill-airdrop.mdx | 9 +++ snippets/setup/agent-skill-zk-nullifier.mdx | 9 +++ zk/examples.mdx | 3 + zk/overview.mdx | 3 + 22 files changed, 513 insertions(+), 8 deletions(-) create mode 100644 ai-tools/prompts.mdx create mode 100644 snippets/ai-prompts/template.mdx create mode 100644 snippets/ai-prompts/ts-cookbook/approve-revoke.mdx create mode 100644 snippets/ai-prompts/ts-cookbook/create-ata.mdx create mode 100644 snippets/ai-prompts/ts-cookbook/create-mint.mdx create mode 100644 snippets/ai-prompts/ts-cookbook/mint-to.mdx create mode 100644 snippets/ai-prompts/ts-cookbook/transfer-interface.mdx create mode 100644 snippets/ai-prompts/ts-cookbook/wrap-unwrap.mdx create mode 100644 snippets/setup/agent-skill-airdrop.mdx create mode 100644 snippets/setup/agent-skill-zk-nullifier.mdx diff --git a/ai-tools/guide.mdx b/ai-tools/guide.mdx index 06728392..cbaf543f 100644 --- a/ai-tools/guide.mdx +++ b/ai-tools/guide.mdx @@ -37,6 +37,16 @@ All skills are included and are auto-discovered based on context. Ask about ligh +## AI Prompts + + + ## MCP The Model Context Protocol (MCP) is an open standard to connect AI apps to data sources and tools. The DeepWiki MCP server provides access to the Light Protocol repository with its search capabilities (AskDevin). @@ -179,14 +189,9 @@ mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "your question") You can specify any public GitHub repo that is indexed with DeepWiki. When you connect to the MCP, you specify the repository when calling the tools. Learn more [here](https://docs.devin.ai/work-with-devin/deepwiki-mcp). -
-

Alternative: DeepWiki Web

- - Ask DeepWiki - -
+ -If you don't have the MCP installed we recommend to use AskDevin in your browser. +If you don't have the MCP installed we recommend to use [AskDevin](https://deepwiki.com/Lightprotocol/light-protocol) in your browser. + + + diff --git a/ai-tools/prompts.mdx b/ai-tools/prompts.mdx new file mode 100644 index 00000000..1e9bcdf9 --- /dev/null +++ b/ai-tools/prompts.mdx @@ -0,0 +1,35 @@ +--- +title: "AI Prompts for Light-Token" +description: "Ready-to-use AI prompts for Light Token instructions. Copy a prompt, paste into your AI chat, and let the agent implement the recipe in your project." +--- + +import CreateMintAiPrompt from "/snippets/ai-prompts/ts-cookbook/create-mint.mdx"; +import CreateAtaAiPrompt from "/snippets/ai-prompts/ts-cookbook/create-ata.mdx"; +import MintToAiPrompt from "/snippets/ai-prompts/ts-cookbook/mint-to.mdx"; +import TransferInterfaceAiPrompt from "/snippets/ai-prompts/ts-cookbook/transfer-interface.mdx"; +import ApproveRevokeAiPrompt from "/snippets/ai-prompts/ts-cookbook/approve-revoke.mdx"; +import WrapUnwrapAiPrompt from "/snippets/ai-prompts/ts-cookbook/wrap-unwrap.mdx"; + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/compressed-tokens/airdrop.mdx b/compressed-tokens/airdrop.mdx index 53d4b9a6..73d85649 100644 --- a/compressed-tokens/airdrop.mdx +++ b/compressed-tokens/airdrop.mdx @@ -8,6 +8,7 @@ keywords: ["solana airdrop", "merkle distributor", "merkle airdrop", "airdrop in import { TokenAccountCompressedVsSpl } from '/snippets/jsx/token-account-compressed-vs-spl.jsx'; import InstallDependencies from '/snippets/setup/install-dependencies-codegroup.mdx'; import SetupEnvironment from '/snippets/setup/setup-environment-tabs.mdx'; +import AgentSkillAirdrop from "/snippets/setup/agent-skill-airdrop.mdx"; @@ -15,6 +16,8 @@ import SetupEnvironment from '/snippets/setup/setup-environment-tabs.mdx'; --- + + diff --git a/compressed-tokens/overview.mdx b/compressed-tokens/overview.mdx index 7a4dcc6a..93273753 100644 --- a/compressed-tokens/overview.mdx +++ b/compressed-tokens/overview.mdx @@ -9,6 +9,9 @@ import AdvancedGuidesTable from "/snippets/overview-tables/compressed-tokens-adv import SetupEnvironment from "/snippets/setup/setup-environment-tabs.mdx"; import InstallDependencies from "/snippets/setup/install-dependencies-codegroup.mdx"; import { TokenAccountCompressedVsSpl } from "/snippets/jsx/token-account-compressed-vs-spl.jsx"; +import AgentSkillAirdrop from "/snippets/setup/agent-skill-airdrop.mdx"; + + **Note: The new [Light Token Program Beta](/light-token/welcome)** is live on Solana Devnet with mainnet expected in Q1 2026. diff --git a/docs.json b/docs.json index 4371769e..96fc4cd6 100644 --- a/docs.json +++ b/docs.json @@ -220,7 +220,8 @@ { "group": "AI Tools", "pages": [ - "ai-tools/guide" + "ai-tools/guide", + "ai-tools/prompts" ] } ] diff --git a/light-token/cookbook/approve-revoke.mdx b/light-token/cookbook/approve-revoke.mdx index b5c1277a..d2e8db11 100644 --- a/light-token/cookbook/approve-revoke.mdx +++ b/light-token/cookbook/approve-revoke.mdx @@ -29,6 +29,7 @@ import RevokeInstructionCode from "/snippets/code-snippets/light-token/approve-r import ApproveAnchorProgramCode from "/snippets/code-snippets/light-token/approve/anchor-program/full-example.mdx"; import RevokeAnchorProgramCode from "/snippets/code-snippets/light-token/revoke/anchor-program/full-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import ApproveRevokeAiPrompt from "/snippets/ai-prompts/ts-cookbook/approve-revoke.mdx"; 1. Approve grants a delegate permission to transfer up to a specified amount of tokens from your account. * Each token account can have only one delegate at a time. @@ -74,6 +75,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; [here](https://github.com/Lightprotocol/examples-light-token/tree/main/typescript-client/actions). + + ### Approve a delegate @@ -91,6 +94,11 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; + + + + + diff --git a/light-token/cookbook/create-ata.mdx b/light-token/cookbook/create-ata.mdx index 56a68f34..c2f31ea0 100644 --- a/light-token/cookbook/create-ata.mdx +++ b/light-token/cookbook/create-ata.mdx @@ -28,6 +28,7 @@ import RustInstructionCode from "/snippets/code-snippets/light-token/create-ata/ import AnchorProgramCode from "/snippets/code-snippets/light-token/create-ata/anchor-program/full-example.mdx"; import AnchorMacroCode from "/snippets/code-snippets/light-token/create-ata/anchor-macro/full-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import CreateAtaAiPrompt from "/snippets/ai-prompts/ts-cookbook/create-ata.mdx"; 1. Associated Light Token accounts can hold token balances of light, SPL, or Token 2022 mints. 2. Light-ATAs are on-chain accounts like SPL ATA's, but the light token program sponsors the rent-exemption cost for you. @@ -58,6 +59,8 @@ Compare to SPL: [here](https://github.com/Lightprotocol/light-protocol/blob/main/js/compressed-token/src/v3/actions/create-ata-interface.ts). + + @@ -76,6 +79,11 @@ Compare to SPL: + + + + +
diff --git a/light-token/cookbook/create-mint.mdx b/light-token/cookbook/create-mint.mdx index 7201ede4..be4dabf1 100644 --- a/light-token/cookbook/create-mint.mdx +++ b/light-token/cookbook/create-mint.mdx @@ -41,6 +41,7 @@ import AnchorProgramCode from "/snippets/code-snippets/light-token/create-mint/a import AnchorMacroCode from "/snippets/code-snippets/light-token/create-mint/anchor-macro/full-example.mdx"; import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import CreateMintAiPrompt from "/snippets/ai-prompts/ts-cookbook/create-mint.mdx"; 1. Mint accounts uniquely represent a token on Solana and store its global metadata. 2. Light mints are on-chain accounts like SPL mints, but the light token program sponsors the rent-exemption cost for you. @@ -78,6 +79,8 @@ Compare to SPL: [here](https://github.com/Lightprotocol/light-protocol/blob/0c4e2417b2df2d564721b89e18d1aad3665120e7/js/compressed-token/src/v3/actions/create-mint-interface.ts). + + @@ -101,6 +104,11 @@ Compare to SPL: + + + + + ### Add Interface PDA to SPL / Token 2022 mints diff --git a/light-token/cookbook/mint-to.mdx b/light-token/cookbook/mint-to.mdx index 4b88748c..4b488d29 100644 --- a/light-token/cookbook/mint-to.mdx +++ b/light-token/cookbook/mint-to.mdx @@ -25,6 +25,7 @@ import RustActionCode from "/snippets/code-snippets/light-token/mint-to/rust-cli import RustInstructionCode from "/snippets/code-snippets/light-token/mint-to/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/mint-to/anchor-program/full-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import MintToAiPrompt from "/snippets/ai-prompts/ts-cookbook/mint-to.mdx"; 1. Mint To creates new tokens of a mint and deposits them to a specified token account. @@ -54,6 +55,8 @@ Compare to SPL: [here](https://github.com/Lightprotocol/light-protocol/blob/0c4e2417b2df2d564721b89e18d1aad3665120e7/js/compressed-token/src/v3/actions/mint-to-interface.ts). + + ### Mint Tokens to Light Token Account @@ -71,6 +74,11 @@ Compare to SPL: + + + + +
diff --git a/light-token/cookbook/transfer-interface.mdx b/light-token/cookbook/transfer-interface.mdx index bcc50c11..3f7ea462 100644 --- a/light-token/cookbook/transfer-interface.mdx +++ b/light-token/cookbook/transfer-interface.mdx @@ -23,6 +23,7 @@ import RustInstructionCode from "/snippets/code-snippets/light-token/transfer-in import AnchorProgramCode from "/snippets/code-snippets/light-token/transfer-interface/anchor-program/full-example.mdx"; import CreateAndTransferCode from "/snippets/code-snippets/light-token/transfer-interface/anchor-program/create-and-transfer-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import TransferInterfaceAiPrompt from "/snippets/ai-prompts/ts-cookbook/transfer-interface.mdx"; @@ -79,6 +80,8 @@ Compare to SPL: [here](https://github.com/Lightprotocol/light-protocol/blob/main/js/compressed-token/src/v3/actions/transfer-interface.ts). + + @@ -97,6 +100,11 @@ Compare to SPL: + + + + + diff --git a/light-token/cookbook/wrap-unwrap.mdx b/light-token/cookbook/wrap-unwrap.mdx index aa39c5d0..017348b7 100644 --- a/light-token/cookbook/wrap-unwrap.mdx +++ b/light-token/cookbook/wrap-unwrap.mdx @@ -16,6 +16,7 @@ import WrapRustActionCode from "/snippets/code-snippets/light-token/wrap/rust-cl import UnwrapRustActionCode from "/snippets/code-snippets/light-token/unwrap/rust-client/action.mdx"; import TokenClientPrerequisites from "/snippets/light-token-guides/light-token-client-prerequisites.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import WrapUnwrapAiPrompt from "/snippets/ai-prompts/ts-cookbook/wrap-unwrap.mdx"; - **Wrap**: Move tokens from SPL/T22 account → Light Token ATA (hot balance) - **Unwrap**: Move tokens from Light Token ATA (hot balance) → SPL/T22 account @@ -32,6 +33,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; + + @@ -73,6 +76,11 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; + + + + + diff --git a/snippets/ai-prompts/template.mdx b/snippets/ai-prompts/template.mdx new file mode 100644 index 00000000..786f9661 --- /dev/null +++ b/snippets/ai-prompts/template.mdx @@ -0,0 +1,55 @@ +```text +--- +description: {{OPERATION_DESCRIPTION}} +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## {{OPERATION_DESCRIPTION}} + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/{{PAGE_SLUG}} +- Skills and resources index: https://zkcompression.com/skill.md +- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js +{{EXTRA_REFS}} + +SPL equivalent: {{SPL_FUNCTION}} → Light Token: {{LIGHT_FUNCTION}} + +### 1. Index project +- Grep `@solana/spl-token|Connection|Keypair` across src/ +- Glob `**/*.ts` for project structure +- Identify: RPC setup, existing token ops, entry point for {{OP_SHORT}} +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the TypeScript Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have token operations to extend, or is this greenfield? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing connection/signer setup is compatible with the cookbook prerequisites +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `tsc --noEmit` +- Bash run existing test suite if present +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/ts-cookbook/approve-revoke.mdx b/snippets/ai-prompts/ts-cookbook/approve-revoke.mdx new file mode 100644 index 00000000..ef65b8a9 --- /dev/null +++ b/snippets/ai-prompts/ts-cookbook/approve-revoke.mdx @@ -0,0 +1,54 @@ +```text +--- +description: Approve and revoke token delegates +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Approve and revoke token delegates + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/approve-revoke +- Skills and resources index: https://zkcompression.com/skill.md +- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js + +SPL equivalent: approve() / revoke() → Light Token: approve() / revoke() + +### 1. Index project +- Grep `@solana/spl-token|Connection|Keypair|approve|revoke|delegate` across src/ +- Glob `**/*.ts` for project structure +- Identify: RPC setup, existing delegation logic, entry point for delegation +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the TypeScript Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have delegate operations to extend, or is this greenfield? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing connection/signer setup is compatible with the cookbook prerequisites +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `tsc --noEmit` +- Bash run existing test suite if present +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/ts-cookbook/create-ata.mdx b/snippets/ai-prompts/ts-cookbook/create-ata.mdx new file mode 100644 index 00000000..5d59f622 --- /dev/null +++ b/snippets/ai-prompts/ts-cookbook/create-ata.mdx @@ -0,0 +1,54 @@ +```text +--- +description: Create rent-free associated token account +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Create rent-free associated token account + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/create-ata +- Skills and resources index: https://zkcompression.com/skill.md +- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js + +SPL equivalent: createAssociatedTokenAccount() → Light Token: createAtaInterface() + +### 1. Index project +- Grep `@solana/spl-token|Connection|Keypair|createAssociatedTokenAccount|createAtaInterface` across src/ +- Glob `**/*.ts` for project structure +- Identify: RPC setup, existing ATA logic, entry point for ATA creation +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the TypeScript Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have ATA operations to extend, or is this greenfield? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing connection/signer setup is compatible with the cookbook prerequisites +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `tsc --noEmit` +- Bash run existing test suite if present +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/ts-cookbook/create-mint.mdx b/snippets/ai-prompts/ts-cookbook/create-mint.mdx new file mode 100644 index 00000000..9534da1d --- /dev/null +++ b/snippets/ai-prompts/ts-cookbook/create-mint.mdx @@ -0,0 +1,54 @@ +```text +--- +description: Add rent-free mint with token metadata +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add rent-free mint with token metadata + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/create-mint +- Skills and resources index: https://zkcompression.com/skill.md +- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js + +SPL equivalent: createMint() → Light Token: createMintInterface() + +### 1. Index project +- Grep `@solana/spl-token|Connection|Keypair|createMint` across src/ +- Glob `**/*.ts` for project structure +- Identify: RPC setup, existing mint logic, entry point for mint creation +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the TypeScript Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have mint operations to extend, or is this greenfield? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing connection/signer setup is compatible with the cookbook prerequisites +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `tsc --noEmit` +- Bash run existing test suite if present +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/ts-cookbook/mint-to.mdx b/snippets/ai-prompts/ts-cookbook/mint-to.mdx new file mode 100644 index 00000000..7e339fcd --- /dev/null +++ b/snippets/ai-prompts/ts-cookbook/mint-to.mdx @@ -0,0 +1,54 @@ +```text +--- +description: Mint tokens to Light Token account +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Mint tokens to Light Token account + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/mint-to +- Skills and resources index: https://zkcompression.com/skill.md +- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js + +SPL equivalent: mintTo() → Light Token: mintToInterface() + +### 1. Index project +- Grep `@solana/spl-token|Connection|Keypair|mintTo|mintToInterface` across src/ +- Glob `**/*.ts` for project structure +- Identify: RPC setup, existing mint logic, entry point for minting +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the TypeScript Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have mint operations to extend, or is this greenfield? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing connection/signer setup is compatible with the cookbook prerequisites +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `tsc --noEmit` +- Bash run existing test suite if present +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/ts-cookbook/transfer-interface.mdx b/snippets/ai-prompts/ts-cookbook/transfer-interface.mdx new file mode 100644 index 00000000..8a8265ba --- /dev/null +++ b/snippets/ai-prompts/ts-cookbook/transfer-interface.mdx @@ -0,0 +1,57 @@ +```text +--- +description: Transfer tokens between Light Token and SPL accounts +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Transfer tokens between Light Token and SPL accounts + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/transfer-interface +- Skills and resources index: https://zkcompression.com/skill.md +- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js + +transferInterface() transfers tokens between token accounts (SPL, Token 2022, or Light Token) in a single call. +- Light Token → Light Token: transfers between Light Token accounts +- SPL → Light Token: locks SPL tokens in interface PDA, mints to Light Token account +- Light Token → SPL: burns Light Token balance, releases SPL tokens from interface PDA + +### 1. Index project +- Grep `@solana/spl-token|Connection|Keypair|transfer|transferInterface` across src/ +- Glob `**/*.ts` for project structure +- Identify: RPC setup, existing transfer logic, entry point for transfers +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the TypeScript Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have transfer operations to extend, or is this greenfield? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing connection/signer setup is compatible with the cookbook prerequisites +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `tsc --noEmit` +- Bash run existing test suite if present +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/ts-cookbook/wrap-unwrap.mdx b/snippets/ai-prompts/ts-cookbook/wrap-unwrap.mdx new file mode 100644 index 00000000..6f0b9e61 --- /dev/null +++ b/snippets/ai-prompts/ts-cookbook/wrap-unwrap.mdx @@ -0,0 +1,55 @@ +```text +--- +description: Wrap and unwrap SPL tokens to Light Token +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Wrap and unwrap SPL tokens to Light Token + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/wrap-unwrap +- Skills and resources index: https://zkcompression.com/skill.md +- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js + +- Wrap: Move tokens from SPL or Token 2022 account → Light Token associated token account (hot balance) +- Unwrap: Move tokens from Light Token associated token account (hot balance) → SPL or Token 2022 account + +### 1. Index project +- Grep `@solana/spl-token|Connection|Keypair|wrap|unwrap|WrapTokens|UnwrapTokens` across src/ +- Glob `**/*.ts` for project structure +- Identify: RPC setup, existing wrap/unwrap logic, entry point for wrap/unwrap +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the TypeScript Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have wrap/unwrap operations to extend, or is this greenfield? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing connection/signer setup is compatible with the cookbook prerequisites +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `tsc --noEmit` +- Bash run existing test suite if present +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/setup/agent-skill-airdrop.mdx b/snippets/setup/agent-skill-airdrop.mdx new file mode 100644 index 00000000..f90145fa --- /dev/null +++ b/snippets/setup/agent-skill-airdrop.mdx @@ -0,0 +1,9 @@ +import InstallAgentSkills from "/snippets/setup/install-agent-skills.mdx"; + + + +Use the [airdrop](https://github.com/Lightprotocol/skills/tree/main/skills/airdrop) agent skill for token distribution and airdrops: + + + + diff --git a/snippets/setup/agent-skill-zk-nullifier.mdx b/snippets/setup/agent-skill-zk-nullifier.mdx new file mode 100644 index 00000000..80809e72 --- /dev/null +++ b/snippets/setup/agent-skill-zk-nullifier.mdx @@ -0,0 +1,9 @@ +import InstallAgentSkills from "/snippets/setup/install-agent-skills.mdx"; + + + +Use the [zk-nullifier](https://github.com/Lightprotocol/skills/tree/main/skills/zk-nullifier) agent skill to build privacy-preserving ZK programs with nullifiers: + + + + diff --git a/zk/examples.mdx b/zk/examples.mdx index 35f7e34f..1040d4d6 100644 --- a/zk/examples.mdx +++ b/zk/examples.mdx @@ -5,6 +5,9 @@ keywords: ["privacy examples solana", "zk examples solana", "private payments ex --- import ZkExamplesTable from "/snippets/overview-tables/zk-examples-table.mdx"; +import AgentSkillZkNullifier from "/snippets/setup/agent-skill-zk-nullifier.mdx"; + + diff --git a/zk/overview.mdx b/zk/overview.mdx index 4ba145ef..a31b601d 100644 --- a/zk/overview.mdx +++ b/zk/overview.mdx @@ -6,9 +6,12 @@ keywords: ["shielded pools", "mixer", "nullifiers on Solana", "zcash on solana", --- import ZkExamplesTable from "/snippets/overview-tables/zk-examples-table.mdx"; +import AgentSkillZkNullifier from "/snippets/setup/agent-skill-zk-nullifier.mdx"; --- + + Building a ZK Solana program requires: 1. Nullifiers to prevent double spending 2. Proof verification From 7a20fb0ddf4f9b73b37c1a16011f645c44a76e60 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Mon, 16 Feb 2026 02:03:15 +0000 Subject: [PATCH 21/27] add ai prompts --- ai-tools/prompts.mdx | 308 ++++++++++++++++-- compressed-tokens/airdrop.mdx | 10 + docs.json | 37 +-- learn/light-token-standard.mdx | 2 +- learn/overview.mdx | 2 +- light-token/cookbook/approve-revoke.mdx | 16 + light-token/cookbook/burn.mdx | 16 + light-token/cookbook/close-token-account.mdx | 16 + light-token/cookbook/create-ata.mdx | 24 ++ light-token/cookbook/create-mint.mdx | 24 ++ light-token/cookbook/create-token-account.mdx | 24 ++ light-token/cookbook/freeze-thaw.mdx | 16 + light-token/cookbook/mint-to.mdx | 16 + light-token/cookbook/transfer-checked.mdx | 16 + light-token/cookbook/transfer-interface.mdx | 18 +- light-token/cookbook/wrap-unwrap.mdx | 8 + light-token/defi/programs-pinocchio.mdx | 10 + light-token/defi/programs.mdx | 9 + light-token/defi/routers.mdx | 10 + light-token/toolkits/for-payments.mdx | 10 + light-token/toolkits/for-privy.mdx | 11 +- light-token/toolkits/for-streaming-mints.mdx | 10 + light-token/toolkits/for-streaming-tokens.mdx | 10 + light-token/toolkits/for-wallets.mdx | 10 + .../compressed-pdas/guides}/client-guide.mdx | 10 +- .../how-to-burn-compressed-accounts.mdx | 10 +- .../how-to-close-compressed-accounts.mdx | 10 +- .../how-to-create-compressed-accounts.mdx | 10 +- .../guides/how-to-create-nullifier-pdas.mdx | 13 +- ...ow-to-reinitialize-compressed-accounts.mdx | 10 +- .../how-to-update-compressed-accounts.mdx | 10 +- pda/compressed-pdas/overview.mdx | 2 +- pda/light-pda/overview.mdx | 10 + resources/sdks/client-development.mdx | 2 +- scripts/copy-privy-snippets.sh | 33 +- .../ai-prompts/anchor-program-template.mdx | 57 ++++ .../anchor-programs/defi-anchor.mdx | 57 ++++ .../anchor-programs/defi-pinocchio.mdx | 57 ++++ .../ai-prompts/anchor-programs/light-pda.mdx | 57 ++++ snippets/ai-prompts/cpi-program-template.mdx | 57 ++++ snippets/ai-prompts/cpi-programs/burn.mdx | 58 ++++ .../ai-prompts/cpi-programs/client-guide.mdx | 63 ++++ snippets/ai-prompts/cpi-programs/close.mdx | 58 ++++ snippets/ai-prompts/cpi-programs/create.mdx | 58 ++++ .../ai-prompts/cpi-programs/reinitialize.mdx | 58 ++++ snippets/ai-prompts/cpi-programs/update.mdx | 58 ++++ snippets/ai-prompts/defi/routers.mdx | 61 ++++ .../program-cookbook/approve-revoke.mdx | 57 ++++ snippets/ai-prompts/program-cookbook/burn.mdx | 56 ++++ .../program-cookbook/close-token-account.mdx | 56 ++++ .../program-cookbook/create-ata-cpi.mdx | 56 ++++ .../program-cookbook/create-ata-macros.mdx | 55 ++++ .../program-cookbook/create-mint-cpi.mdx | 57 ++++ .../program-cookbook/create-mint-macros.mdx | 56 ++++ .../create-token-account-cpi.mdx | 56 ++++ .../create-token-account-macros.mdx | 55 ++++ .../program-cookbook/freeze-thaw.mdx | 57 ++++ .../ai-prompts/program-cookbook/mint-to.mdx | 56 ++++ .../program-cookbook/transfer-checked.mdx | 56 ++++ .../program-cookbook/transfer-interface.mdx | 57 ++++ .../rust-cookbook/approve-revoke.mdx | 56 ++++ snippets/ai-prompts/rust-cookbook/burn.mdx | 56 ++++ .../rust-cookbook/close-token-account.mdx | 56 ++++ .../ai-prompts/rust-cookbook/create-ata.mdx | 56 ++++ .../ai-prompts/rust-cookbook/create-mint.mdx | 56 ++++ .../rust-cookbook/create-token-account.mdx | 56 ++++ .../ai-prompts/rust-cookbook/freeze-thaw.mdx | 60 ++++ snippets/ai-prompts/rust-cookbook/mint-to.mdx | 56 ++++ .../rust-cookbook/transfer-checked.mdx | 58 ++++ .../rust-cookbook/transfer-interface.mdx | 61 ++++ .../ai-prompts/rust-cookbook/wrap-unwrap.mdx | 59 ++++ snippets/ai-prompts/rust-template.mdx | 57 ++++ snippets/ai-prompts/streaming/mints.mdx | 57 ++++ snippets/ai-prompts/streaming/tokens.mdx | 60 ++++ snippets/ai-prompts/toolkits/airdrop.mdx | 62 ++++ snippets/ai-prompts/toolkits/nullifiers.mdx | 63 ++++ snippets/ai-prompts/toolkits/payments.mdx | 67 ++++ snippets/ai-prompts/toolkits/wallets.mdx | 68 ++++ snippets/ai-prompts/wallets/privy.mdx | 67 ++++ .../code-snippets/privy/balances/nodejs.mdx | 148 +++++---- .../code-snippets/privy/balances/react.mdx | 172 +++++++++- .../privy/helpers/sign-and-send-batches.mdx | 46 +++ .../privy/transaction-history/nodejs.mdx | 3 +- .../privy/transaction-history/react.mdx | 66 +++- .../code-snippets/privy/transfer/nodejs.mdx | 6 +- .../code-snippets/privy/transfer/react.mdx | 72 +++- .../code-snippets/privy/unwrap/nodejs.mdx | 8 +- snippets/code-snippets/privy/unwrap/react.mdx | 79 ++++- snippets/code-snippets/privy/wrap/nodejs.mdx | 7 +- snippets/code-snippets/privy/wrap/react.mdx | 100 +++++- snippets/setup/register-spl-mint.mdx | 2 +- 91 files changed, 3879 insertions(+), 143 deletions(-) rename {client-library => pda/compressed-pdas/guides}/client-guide.mdx (98%) create mode 100644 snippets/ai-prompts/anchor-program-template.mdx create mode 100644 snippets/ai-prompts/anchor-programs/defi-anchor.mdx create mode 100644 snippets/ai-prompts/anchor-programs/defi-pinocchio.mdx create mode 100644 snippets/ai-prompts/anchor-programs/light-pda.mdx create mode 100644 snippets/ai-prompts/cpi-program-template.mdx create mode 100644 snippets/ai-prompts/cpi-programs/burn.mdx create mode 100644 snippets/ai-prompts/cpi-programs/client-guide.mdx create mode 100644 snippets/ai-prompts/cpi-programs/close.mdx create mode 100644 snippets/ai-prompts/cpi-programs/create.mdx create mode 100644 snippets/ai-prompts/cpi-programs/reinitialize.mdx create mode 100644 snippets/ai-prompts/cpi-programs/update.mdx create mode 100644 snippets/ai-prompts/defi/routers.mdx create mode 100644 snippets/ai-prompts/program-cookbook/approve-revoke.mdx create mode 100644 snippets/ai-prompts/program-cookbook/burn.mdx create mode 100644 snippets/ai-prompts/program-cookbook/close-token-account.mdx create mode 100644 snippets/ai-prompts/program-cookbook/create-ata-cpi.mdx create mode 100644 snippets/ai-prompts/program-cookbook/create-ata-macros.mdx create mode 100644 snippets/ai-prompts/program-cookbook/create-mint-cpi.mdx create mode 100644 snippets/ai-prompts/program-cookbook/create-mint-macros.mdx create mode 100644 snippets/ai-prompts/program-cookbook/create-token-account-cpi.mdx create mode 100644 snippets/ai-prompts/program-cookbook/create-token-account-macros.mdx create mode 100644 snippets/ai-prompts/program-cookbook/freeze-thaw.mdx create mode 100644 snippets/ai-prompts/program-cookbook/mint-to.mdx create mode 100644 snippets/ai-prompts/program-cookbook/transfer-checked.mdx create mode 100644 snippets/ai-prompts/program-cookbook/transfer-interface.mdx create mode 100644 snippets/ai-prompts/rust-cookbook/approve-revoke.mdx create mode 100644 snippets/ai-prompts/rust-cookbook/burn.mdx create mode 100644 snippets/ai-prompts/rust-cookbook/close-token-account.mdx create mode 100644 snippets/ai-prompts/rust-cookbook/create-ata.mdx create mode 100644 snippets/ai-prompts/rust-cookbook/create-mint.mdx create mode 100644 snippets/ai-prompts/rust-cookbook/create-token-account.mdx create mode 100644 snippets/ai-prompts/rust-cookbook/freeze-thaw.mdx create mode 100644 snippets/ai-prompts/rust-cookbook/mint-to.mdx create mode 100644 snippets/ai-prompts/rust-cookbook/transfer-checked.mdx create mode 100644 snippets/ai-prompts/rust-cookbook/transfer-interface.mdx create mode 100644 snippets/ai-prompts/rust-cookbook/wrap-unwrap.mdx create mode 100644 snippets/ai-prompts/rust-template.mdx create mode 100644 snippets/ai-prompts/streaming/mints.mdx create mode 100644 snippets/ai-prompts/streaming/tokens.mdx create mode 100644 snippets/ai-prompts/toolkits/airdrop.mdx create mode 100644 snippets/ai-prompts/toolkits/nullifiers.mdx create mode 100644 snippets/ai-prompts/toolkits/payments.mdx create mode 100644 snippets/ai-prompts/toolkits/wallets.mdx create mode 100644 snippets/ai-prompts/wallets/privy.mdx create mode 100644 snippets/code-snippets/privy/helpers/sign-and-send-batches.mdx diff --git a/ai-tools/prompts.mdx b/ai-tools/prompts.mdx index 1e9bcdf9..4bbdb2d2 100644 --- a/ai-tools/prompts.mdx +++ b/ai-tools/prompts.mdx @@ -1,35 +1,305 @@ --- -title: "AI Prompts for Light-Token" -description: "Ready-to-use AI prompts for Light Token instructions. Copy a prompt, paste into your AI chat, and let the agent implement the recipe in your project." +title: "AI prompts" +description: "Ready-to-use AI prompts for Light Protocol. Copy a prompt, paste into your AI coding agent, and let it implement the recipe in your project." --- -import CreateMintAiPrompt from "/snippets/ai-prompts/ts-cookbook/create-mint.mdx"; -import CreateAtaAiPrompt from "/snippets/ai-prompts/ts-cookbook/create-ata.mdx"; -import MintToAiPrompt from "/snippets/ai-prompts/ts-cookbook/mint-to.mdx"; -import TransferInterfaceAiPrompt from "/snippets/ai-prompts/ts-cookbook/transfer-interface.mdx"; -import ApproveRevokeAiPrompt from "/snippets/ai-prompts/ts-cookbook/approve-revoke.mdx"; -import WrapUnwrapAiPrompt from "/snippets/ai-prompts/ts-cookbook/wrap-unwrap.mdx"; +{/* ts-cookbook */} +import TsCreateMint from "/snippets/ai-prompts/ts-cookbook/create-mint.mdx"; +import TsCreateAta from "/snippets/ai-prompts/ts-cookbook/create-ata.mdx"; +import TsMintTo from "/snippets/ai-prompts/ts-cookbook/mint-to.mdx"; +import TsTransferInterface from "/snippets/ai-prompts/ts-cookbook/transfer-interface.mdx"; +import TsApproveRevoke from "/snippets/ai-prompts/ts-cookbook/approve-revoke.mdx"; +import TsWrapUnwrap from "/snippets/ai-prompts/ts-cookbook/wrap-unwrap.mdx"; - - +{/* rust-cookbook */} +import RustCreateMint from "/snippets/ai-prompts/rust-cookbook/create-mint.mdx"; +import RustCreateAta from "/snippets/ai-prompts/rust-cookbook/create-ata.mdx"; +import RustCreateTokenAccount from "/snippets/ai-prompts/rust-cookbook/create-token-account.mdx"; +import RustMintTo from "/snippets/ai-prompts/rust-cookbook/mint-to.mdx"; +import RustTransferInterface from "/snippets/ai-prompts/rust-cookbook/transfer-interface.mdx"; +import RustTransferChecked from "/snippets/ai-prompts/rust-cookbook/transfer-checked.mdx"; +import RustApproveRevoke from "/snippets/ai-prompts/rust-cookbook/approve-revoke.mdx"; +import RustFreezeThaw from "/snippets/ai-prompts/rust-cookbook/freeze-thaw.mdx"; +import RustWrapUnwrap from "/snippets/ai-prompts/rust-cookbook/wrap-unwrap.mdx"; +import RustCloseTokenAccount from "/snippets/ai-prompts/rust-cookbook/close-token-account.mdx"; +import RustBurn from "/snippets/ai-prompts/rust-cookbook/burn.mdx"; + +{/* program-cookbook */} +import ProgCreateMintCpi from "/snippets/ai-prompts/program-cookbook/create-mint-cpi.mdx"; +import ProgCreateMintMacros from "/snippets/ai-prompts/program-cookbook/create-mint-macros.mdx"; +import ProgCreateAtaCpi from "/snippets/ai-prompts/program-cookbook/create-ata-cpi.mdx"; +import ProgCreateAtaMacros from "/snippets/ai-prompts/program-cookbook/create-ata-macros.mdx"; +import ProgCreateTokenAccountCpi from "/snippets/ai-prompts/program-cookbook/create-token-account-cpi.mdx"; +import ProgCreateTokenAccountMacros from "/snippets/ai-prompts/program-cookbook/create-token-account-macros.mdx"; +import ProgMintTo from "/snippets/ai-prompts/program-cookbook/mint-to.mdx"; +import ProgTransferInterface from "/snippets/ai-prompts/program-cookbook/transfer-interface.mdx"; +import ProgTransferChecked from "/snippets/ai-prompts/program-cookbook/transfer-checked.mdx"; +import ProgApproveRevoke from "/snippets/ai-prompts/program-cookbook/approve-revoke.mdx"; +import ProgFreezeThaw from "/snippets/ai-prompts/program-cookbook/freeze-thaw.mdx"; +import ProgCloseTokenAccount from "/snippets/ai-prompts/program-cookbook/close-token-account.mdx"; +import ProgBurn from "/snippets/ai-prompts/program-cookbook/burn.mdx"; + +{/* anchor-programs */} +import DefiAnchor from "/snippets/ai-prompts/anchor-programs/defi-anchor.mdx"; +import DefiPinocchio from "/snippets/ai-prompts/anchor-programs/defi-pinocchio.mdx"; +import LightPda from "/snippets/ai-prompts/anchor-programs/light-pda.mdx"; + +{/* cpi-programs */} +import CpiCreate from "/snippets/ai-prompts/cpi-programs/create.mdx"; +import CpiUpdate from "/snippets/ai-prompts/cpi-programs/update.mdx"; +import CpiClose from "/snippets/ai-prompts/cpi-programs/close.mdx"; +import CpiReinitialize from "/snippets/ai-prompts/cpi-programs/reinitialize.mdx"; +import CpiBurn from "/snippets/ai-prompts/cpi-programs/burn.mdx"; +import CpiClientGuide from "/snippets/ai-prompts/cpi-programs/client-guide.mdx"; + +{/* defi - routers */} +import Routers from "/snippets/ai-prompts/defi/routers.mdx"; + +{/* streaming */} +import StreamingMints from "/snippets/ai-prompts/streaming/mints.mdx"; +import StreamingTokens from "/snippets/ai-prompts/streaming/tokens.mdx"; + +{/* toolkits */} +import Payments from "/snippets/ai-prompts/toolkits/payments.mdx"; +import WalletsIntegration from "/snippets/ai-prompts/toolkits/wallets.mdx"; +import Nullifiers from "/snippets/ai-prompts/toolkits/nullifiers.mdx"; +import Airdrop from "/snippets/ai-prompts/toolkits/airdrop.mdx"; + +{/* wallets */} +import Privy from "/snippets/ai-prompts/wallets/privy.mdx"; + +{/* migration */} +import V1ToV2Migration from "/snippets/ai-prompts/v1-to-v2-migration.mdx"; + +## Light Token Recipes + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## DeFi + + + + + + + + + + + + + +## Data Streaming + + + - - + + + + +## Stablecoin Payments + + + + + + + + + +## Wallets + + + + + + + + + +## Light-PDA + + + + + +## Compressed PDA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +## Token Distribution + + + \ No newline at end of file diff --git a/compressed-tokens/airdrop.mdx b/compressed-tokens/airdrop.mdx index 73d85649..aec6b849 100644 --- a/compressed-tokens/airdrop.mdx +++ b/compressed-tokens/airdrop.mdx @@ -9,6 +9,7 @@ import { TokenAccountCompressedVsSpl } from '/snippets/jsx/token-account-compres import InstallDependencies from '/snippets/setup/install-dependencies-codegroup.mdx'; import SetupEnvironment from '/snippets/setup/setup-environment-tabs.mdx'; import AgentSkillAirdrop from "/snippets/setup/agent-skill-airdrop.mdx"; +import AirdropAiPrompt from "/snippets/ai-prompts/toolkits/airdrop.mdx"; @@ -18,6 +19,9 @@ import AgentSkillAirdrop from "/snippets/setup/agent-skill-airdrop.mdx"; + + + @@ -1052,3 +1056,9 @@ The programs are reference implementations and should be audited before producti + + + + + + diff --git a/docs.json b/docs.json index 96fc4cd6..5126a337 100644 --- a/docs.json +++ b/docs.json @@ -71,7 +71,7 @@ "group": "Compressed PDA", "pages": [ "pda/compressed-pdas/overview", - "client-library/client-guide", + "pda/compressed-pdas/guides/client-guide", { "group": "Program Guides", "expanded": true, @@ -141,16 +141,6 @@ } ] }, - { - "group": "Resources", - "pages": [ - "api-reference/sdk", - "resources/anchor-constraints", - "resources/addresses-and-urls", - "references/migration-v1-to-v2", - "resources/cli-installation" - ] - }, { "group": "Learn", "pages": [ @@ -169,10 +159,15 @@ ] }, { - "group": "References", + "group": "Reference", "pages": [ - "compressed-tokens/overview", + "api-reference/sdk", + "resources/anchor-constraints", + "resources/addresses-and-urls", + "resources/cli-installation", "references/terminology", + "references/migration-v1-to-v2", + "compressed-tokens/overview", "references/whitepaper", "references/node-operators", "references/security" @@ -303,27 +298,31 @@ "redirects": [ { "source": "/landing", - "destination": "/home" + "destination": "https://zkcompression.com/home" }, { "source": "/welcome", - "destination": "/home" + "destination": "https://zkcompression.com/home" }, { "source": "/learn/ai-tools-guide", - "destination": "/ai-tools/guide" + "destination": "https://zkcompression.com/ai-tools/guide" }, { "source": "/resources/sdks/client-development", - "destination": "/api-reference/sdk" + "destination": "https://zkcompression.com/api-reference/sdk" }, { "source": "/resources/sdks/program-development", - "destination": "/api-reference/sdk" + "destination": "https://zkcompression.com/api-reference/sdk" }, { "source": "/compressed-tokens/for-privy", - "destination": "/light-token/toolkits/for-privy" + "destination": "https://zkcompression.com/light-token/toolkits/for-privy" + }, + { + "source": "/client-library/client-guide", + "destination": "https://zkcompression.com/pda/compressed-pdas/guides/client-guide" } ] } diff --git a/learn/light-token-standard.mdx b/learn/light-token-standard.mdx index 5957e96c..1c944842 100644 --- a/learn/light-token-standard.mdx +++ b/learn/light-token-standard.mdx @@ -1,5 +1,5 @@ --- -title: Core Concepts to the Light Token Program (Beta) +title: Core concepts of the Light Token program (Beta) sidebarTitle: Core Concepts Light Token description: The Light Token Program is a high performance token program that reduces the cost of account creations by 200x, while being more CU efficient than SPL on hot paths. keywords: ["light token standard on solana", "token 2022 on solana", "token extensions on solana", "spl token on solana", "rent free tokens on solana"] diff --git a/learn/overview.mdx b/learn/overview.mdx index baebc649..9e4bedf2 100644 --- a/learn/overview.mdx +++ b/learn/overview.mdx @@ -1,5 +1,5 @@ --- -title: Overview to Core Concepts +title: Overview of core concepts sidebarTitle: Overview description: Learn about Light Token and ZK Compression Core. keywords: ["zk compression on solana", "scalable solana infrastructure", "compressed accounts on solana", "privacy on solana", "zk on solana", "shielded transactions on solana"] diff --git a/light-token/cookbook/approve-revoke.mdx b/light-token/cookbook/approve-revoke.mdx index d2e8db11..d939d82e 100644 --- a/light-token/cookbook/approve-revoke.mdx +++ b/light-token/cookbook/approve-revoke.mdx @@ -30,6 +30,8 @@ import ApproveAnchorProgramCode from "/snippets/code-snippets/light-token/approv import RevokeAnchorProgramCode from "/snippets/code-snippets/light-token/revoke/anchor-program/full-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; import ApproveRevokeAiPrompt from "/snippets/ai-prompts/ts-cookbook/approve-revoke.mdx"; +import RustApproveRevokeAiPrompt from "/snippets/ai-prompts/rust-cookbook/approve-revoke.mdx"; +import ProgramApproveRevokeAiPrompt from "/snippets/ai-prompts/program-cookbook/approve-revoke.mdx"; 1. Approve grants a delegate permission to transfer up to a specified amount of tokens from your account. * Each token account can have only one delegate at a time. @@ -129,6 +131,8 @@ import ApproveRevokeAiPrompt from "/snippets/ai-prompts/ts-cookbook/approve-revo + + ### Prerequisites @@ -170,8 +174,15 @@ import ApproveRevokeAiPrompt from "/snippets/ai-prompts/ts-cookbook/approve-revo + + + + + + + Find [a full code example at the end](#full-code-example). @@ -297,6 +308,11 @@ revoke_cpi.invoke_signed(&[signer_seeds])?; + + + + + diff --git a/light-token/cookbook/burn.mdx b/light-token/cookbook/burn.mdx index 804ddf44..c7a7cde0 100644 --- a/light-token/cookbook/burn.mdx +++ b/light-token/cookbook/burn.mdx @@ -17,6 +17,8 @@ import RustInstructionCode from "/snippets/code-snippets/light-token/burn/rust-c import BurnCheckedRustInstructionCode from "/snippets/code-snippets/light-token/burn-checked/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/burn/anchor-program/full-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import RustBurnAiPrompt from "/snippets/ai-prompts/rust-cookbook/burn.mdx"; +import ProgramBurnAiPrompt from "/snippets/ai-prompts/program-cookbook/burn.mdx"; 1. Burn permanently destroys tokens by reducing the balance in a token account. @@ -38,6 +40,8 @@ Compare to SPL: language="rust" /> + + ### Prerequisites @@ -61,8 +65,15 @@ Compare to SPL: + + + + + + + Find [a full code example at the end](#full-code-example). @@ -125,6 +136,11 @@ BurnCpi { + + + + + diff --git a/light-token/cookbook/close-token-account.mdx b/light-token/cookbook/close-token-account.mdx index 4a560c10..54da981a 100644 --- a/light-token/cookbook/close-token-account.mdx +++ b/light-token/cookbook/close-token-account.mdx @@ -18,6 +18,8 @@ import { import RustInstructionCode from "/snippets/code-snippets/light-token/close-token-account/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/close-token-account/anchor-program/full-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import RustCloseTokenAccountAiPrompt from "/snippets/ai-prompts/rust-cookbook/close-token-account.mdx"; +import ProgramCloseTokenAccountAiPrompt from "/snippets/ai-prompts/program-cookbook/close-token-account.mdx"; 1. Closing a Light Token account transfers remaining lamports to a destination account and the rent sponsor can reclaim sponsored rent. 2. Light token accounts can be closed by the owner. @@ -45,6 +47,8 @@ Compare to SPL: language="rust" /> + + ### Prerequisites @@ -69,8 +73,15 @@ Compare to SPL: + + + + + + + Find [a full code example at the end](#full-code-example). @@ -132,6 +143,11 @@ CloseAccountCpi { + + + + + diff --git a/light-token/cookbook/create-ata.mdx b/light-token/cookbook/create-ata.mdx index c2f31ea0..185aae42 100644 --- a/light-token/cookbook/create-ata.mdx +++ b/light-token/cookbook/create-ata.mdx @@ -29,6 +29,9 @@ import AnchorProgramCode from "/snippets/code-snippets/light-token/create-ata/an import AnchorMacroCode from "/snippets/code-snippets/light-token/create-ata/anchor-macro/full-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; import CreateAtaAiPrompt from "/snippets/ai-prompts/ts-cookbook/create-ata.mdx"; +import RustCreateAtaAiPrompt from "/snippets/ai-prompts/rust-cookbook/create-ata.mdx"; +import ProgramCreateAtaCpiAiPrompt from "/snippets/ai-prompts/program-cookbook/create-ata-cpi.mdx"; +import ProgramCreateAtaMacrosAiPrompt from "/snippets/ai-prompts/program-cookbook/create-ata-macros.mdx"; 1. Associated Light Token accounts can hold token balances of light, SPL, or Token 2022 mints. 2. Light-ATAs are on-chain accounts like SPL ATA's, but the light token program sponsors the rent-exemption cost for you. @@ -101,6 +104,8 @@ Compare to SPL: language="rust" /> + + @@ -129,11 +134,18 @@ Compare to SPL: + + + + + + + Compare to SPL: @@ -223,8 +235,15 @@ CreateAssociatedAccountCpi { + + + + + + + Compare to SPL: @@ -308,6 +327,11 @@ pub ata: UncheckedAccount<'info>, + + + + + diff --git a/light-token/cookbook/create-mint.mdx b/light-token/cookbook/create-mint.mdx index be4dabf1..431a819b 100644 --- a/light-token/cookbook/create-mint.mdx +++ b/light-token/cookbook/create-mint.mdx @@ -42,6 +42,9 @@ import AnchorMacroCode from "/snippets/code-snippets/light-token/create-mint/anc import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; import CreateMintAiPrompt from "/snippets/ai-prompts/ts-cookbook/create-mint.mdx"; +import RustCreateMintAiPrompt from "/snippets/ai-prompts/rust-cookbook/create-mint.mdx"; +import ProgramCreateMintCpiAiPrompt from "/snippets/ai-prompts/program-cookbook/create-mint-cpi.mdx"; +import ProgramCreateMintMacrosAiPrompt from "/snippets/ai-prompts/program-cookbook/create-mint-macros.mdx"; 1. Mint accounts uniquely represent a token on Solana and store its global metadata. 2. Light mints are on-chain accounts like SPL mints, but the light token program sponsors the rent-exemption cost for you. @@ -174,6 +177,8 @@ Compare to SPL: language="rust" /> + + ### Prerequisites @@ -201,12 +206,19 @@ Compare to SPL: + + + + + + + Compare to SPL: @@ -421,9 +433,16 @@ CreateMintCpi::new( + + + + + + + Compare to SPL: @@ -548,6 +567,11 @@ pub mint: UncheckedAccount<'info>, + + + + + diff --git a/light-token/cookbook/create-token-account.mdx b/light-token/cookbook/create-token-account.mdx index 88761d9a..5d6e4280 100644 --- a/light-token/cookbook/create-token-account.mdx +++ b/light-token/cookbook/create-token-account.mdx @@ -23,6 +23,9 @@ import RustInstructionCode from "/snippets/code-snippets/light-token/create-toke import AnchorProgramCode from "/snippets/code-snippets/light-token/create-token-account/anchor-program/full-example.mdx"; import AnchorMacroCode from "/snippets/code-snippets/light-token/create-token-account/anchor-macro/full-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import RustCreateTokenAccountAiPrompt from "/snippets/ai-prompts/rust-cookbook/create-token-account.mdx"; +import ProgramCreateTokenAccountCpiAiPrompt from "/snippets/ai-prompts/program-cookbook/create-token-account-cpi.mdx"; +import ProgramCreateTokenAccountMacrosAiPrompt from "/snippets/ai-prompts/program-cookbook/create-token-account-macros.mdx"; 1. Light token accounts are Solana accounts that hold token balances of light, SPL, or Token 2022 mints. 2. Light token accounts are on-chain accounts like SPL ATA's, but the light token program sponsors the rent-exemption cost for you. @@ -48,6 +51,8 @@ Compare to SPL: language="rust" /> + + ### Prerequisites @@ -71,12 +76,19 @@ Compare to SPL: + + + + + + + Compare to SPL: @@ -158,8 +170,15 @@ CreateTokenAccountCpi { + + + + + + + Compare to SPL: @@ -247,6 +266,11 @@ pub vault: UncheckedAccount<'info>, + + + + + diff --git a/light-token/cookbook/freeze-thaw.mdx b/light-token/cookbook/freeze-thaw.mdx index 2c3491f7..f74b2935 100644 --- a/light-token/cookbook/freeze-thaw.mdx +++ b/light-token/cookbook/freeze-thaw.mdx @@ -20,6 +20,8 @@ import ThawInstructionCode from "/snippets/code-snippets/light-token/freeze-thaw import FreezeAnchorProgramCode from "/snippets/code-snippets/light-token/freeze/anchor-program/full-example.mdx"; import ThawAnchorProgramCode from "/snippets/code-snippets/light-token/thaw/anchor-program/full-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import RustFreezeThawAiPrompt from "/snippets/ai-prompts/rust-cookbook/freeze-thaw.mdx"; +import ProgramFreezeThawAiPrompt from "/snippets/ai-prompts/program-cookbook/freeze-thaw.mdx"; 1. Freeze prevents all transfers or token burns from a specific Light Token account. 2. Once frozen, the account cannot send tokens, receive tokens, or be closed until it is thawed. @@ -57,6 +59,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; + + ### Prerequisites @@ -92,8 +96,15 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; + + + + + + + Find [a full code example at the end](#full-code-example). @@ -215,6 +226,11 @@ ThawCpi { + + + + + diff --git a/light-token/cookbook/mint-to.mdx b/light-token/cookbook/mint-to.mdx index 4b488d29..86f323fc 100644 --- a/light-token/cookbook/mint-to.mdx +++ b/light-token/cookbook/mint-to.mdx @@ -26,6 +26,8 @@ import RustInstructionCode from "/snippets/code-snippets/light-token/mint-to/rus import AnchorProgramCode from "/snippets/code-snippets/light-token/mint-to/anchor-program/full-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; import MintToAiPrompt from "/snippets/ai-prompts/ts-cookbook/mint-to.mdx"; +import RustMintToAiPrompt from "/snippets/ai-prompts/rust-cookbook/mint-to.mdx"; +import ProgramMintToAiPrompt from "/snippets/ai-prompts/program-cookbook/mint-to.mdx"; 1. Mint To creates new tokens of a mint and deposits them to a specified token account. @@ -96,6 +98,8 @@ Compare to SPL: language="rust" /> + + ### Prerequisites @@ -123,8 +127,15 @@ Compare to SPL: + + + + + + + Find [a full code example at the end](#full-code-example). @@ -193,6 +204,11 @@ MintToCpi { + + + + + diff --git a/light-token/cookbook/transfer-checked.mdx b/light-token/cookbook/transfer-checked.mdx index 141c4263..0c906f7e 100644 --- a/light-token/cookbook/transfer-checked.mdx +++ b/light-token/cookbook/transfer-checked.mdx @@ -12,6 +12,8 @@ import RustActionCode from "/snippets/code-snippets/light-token/transfer-checked import RustInstructionCode from "/snippets/code-snippets/light-token/transfer-checked/rust-client/instruction.mdx"; import AnchorProgramCode from "/snippets/code-snippets/light-token/transfer-checked/anchor-program/full-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import RustTransferCheckedAiPrompt from "/snippets/ai-prompts/rust-cookbook/transfer-checked.mdx"; +import ProgramTransferCheckedAiPrompt from "/snippets/ai-prompts/program-cookbook/transfer-checked.mdx"; 1. TransferChecked validates that the decimals parameter matches the mint's decimals. 2. Use for Light→Light transfers when you need decimal verification. @@ -22,6 +24,8 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; + + ### Prerequisites @@ -49,8 +53,15 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; + + + + + + + Find [a full code example at the end](#full-code-example). @@ -116,6 +127,11 @@ TransferCheckedCpi { + + + + + diff --git a/light-token/cookbook/transfer-interface.mdx b/light-token/cookbook/transfer-interface.mdx index 3f7ea462..c07144c2 100644 --- a/light-token/cookbook/transfer-interface.mdx +++ b/light-token/cookbook/transfer-interface.mdx @@ -24,6 +24,8 @@ import AnchorProgramCode from "/snippets/code-snippets/light-token/transfer-inte import CreateAndTransferCode from "/snippets/code-snippets/light-token/transfer-interface/anchor-program/create-and-transfer-example.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; import TransferInterfaceAiPrompt from "/snippets/ai-prompts/ts-cookbook/transfer-interface.mdx"; +import RustTransferInterfaceAiPrompt from "/snippets/ai-prompts/rust-cookbook/transfer-interface.mdx"; +import ProgramTransferInterfaceAiPrompt from "/snippets/ai-prompts/program-cookbook/transfer-interface.mdx";
@@ -120,6 +122,8 @@ Use the unified `TransferInterface` to transfer tokens between token accounts (S language="rust" /> + + ### Prerequisites @@ -131,7 +135,7 @@ Use the unified `TransferInterface` to transfer tokens between token accounts (S ### Transfer Interface -The example transfers +The example transfers 1. SPL token -> Light Token, 2. Light Token -> Light Token, and 3. Light Token -> SPL token. @@ -151,10 +155,17 @@ The example transfers + + + + + + + Find [a full code example at the end](#full-code-example). @@ -238,6 +249,11 @@ Uses the `#[light_account(init, associated_token::...)]` macro to create the des + + + + + diff --git a/light-token/cookbook/wrap-unwrap.mdx b/light-token/cookbook/wrap-unwrap.mdx index 017348b7..2b432e67 100644 --- a/light-token/cookbook/wrap-unwrap.mdx +++ b/light-token/cookbook/wrap-unwrap.mdx @@ -17,6 +17,7 @@ import UnwrapRustActionCode from "/snippets/code-snippets/light-token/unwrap/rus import TokenClientPrerequisites from "/snippets/light-token-guides/light-token-client-prerequisites.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; import WrapUnwrapAiPrompt from "/snippets/ai-prompts/ts-cookbook/wrap-unwrap.mdx"; +import RustWrapUnwrapAiPrompt from "/snippets/ai-prompts/rust-cookbook/wrap-unwrap.mdx"; - **Wrap**: Move tokens from SPL/T22 account → Light Token ATA (hot balance) - **Unwrap**: Move tokens from Light Token ATA (hot balance) → SPL/T22 account @@ -87,6 +88,8 @@ import WrapUnwrapAiPrompt from "/snippets/ai-prompts/ts-cookbook/wrap-unwrap.mdx + + @@ -139,6 +142,11 @@ import WrapUnwrapAiPrompt from "/snippets/ai-prompts/ts-cookbook/wrap-unwrap.mdx + + + + + diff --git a/light-token/defi/programs-pinocchio.mdx b/light-token/defi/programs-pinocchio.mdx index ec6f11c6..61f988ac 100644 --- a/light-token/defi/programs-pinocchio.mdx +++ b/light-token/defi/programs-pinocchio.mdx @@ -4,6 +4,7 @@ description: "Build high-performance DeFi programs with rent-free accounts using --- import AgentSkillDefiProgram from "/snippets/setup/agent-skill-defi-program.mdx"; +import DefiPinocchioAiPrompt from "/snippets/ai-prompts/anchor-programs/defi-pinocchio.mdx"; The Light-SDK sponsors rent-exemption for your PDAs, token accounts, and mints. Your program logic stays the same. @@ -31,6 +32,9 @@ If you use Anchor instead of Pinocchio, see [Program Integration](./programs). Complete pinocchio Swap reference implementation: [pinocchio-swap](https://github.com/Lightprotocol/examples-light-token/tree/simplify-trait/pinocchio/swap) + + + ## Step 1: Dependencies ```toml @@ -291,6 +295,12 @@ pub fn process( ``` + + + + + + --- ## Client SDK diff --git a/light-token/defi/programs.mdx b/light-token/defi/programs.mdx index d78e16e9..c171dc49 100644 --- a/light-token/defi/programs.mdx +++ b/light-token/defi/programs.mdx @@ -4,6 +4,7 @@ description: "Build high-performance DeFi programs with rent-free accounts" --- import AgentSkillDefiProgram from "/snippets/setup/agent-skill-defi-program.mdx"; +import DefiAnchorAiPrompt from "/snippets/ai-prompts/anchor-programs/defi-anchor.mdx"; The Light-SDK sponsors rent-exemption for your PDAs, token accounts, and mints. Your program logic stays the same. @@ -34,6 +35,9 @@ If you don't use Anchor, see the [Pinocchio Programs](./programs-pinocchio) guid You can find a complete rent-free AMM reference implementation [here](https://github.com/Lightprotocol/cp-swap-reference). + + + ## Step 1: Dependencies ```toml @@ -348,6 +352,11 @@ pub fn process_initialize_pool(ctx: Context, params: InitializeP + + + + + --- diff --git a/light-token/defi/routers.mdx b/light-token/defi/routers.mdx index 2f912f52..9d24ca69 100644 --- a/light-token/defi/routers.mdx +++ b/light-token/defi/routers.mdx @@ -4,6 +4,7 @@ description: "Add support for rent-free AMMs on Solana." --- import AgentSkillDefiRouter from "/snippets/setup/agent-skill-defi-router.mdx"; +import RoutersAiPrompt from "/snippets/ai-prompts/defi/routers.mdx"; Your existing quoting, routing, and swap logic stays the same. The only addition: when a market has cold accounts, detect them, and prepend load instructions before the swap. @@ -20,6 +21,9 @@ The only addition: when a market has cold accounts, detect them, and prepend loa + + + ## Detecting cold accounts Add a cache for cold accounts. This can be independent from your regular account cache. @@ -310,3 +314,9 @@ API is in Beta and subject to change. Questions or need hands-on support? [Telegram](https://t.me/swen_light) | [email](mailto:support@lightprotocol.com) | [Discord](https://discord.com/invite/7cJ8BhAXhu) + + + + + + diff --git a/light-token/toolkits/for-payments.mdx b/light-token/toolkits/for-payments.mdx index 0873f8aa..6c0c3c27 100644 --- a/light-token/toolkits/for-payments.mdx +++ b/light-token/toolkits/for-payments.mdx @@ -9,6 +9,7 @@ import { CodeCompare } from "/snippets/jsx/code-compare.jsx"; import ToolkitsSetup from "/snippets/setup/toolkits-setup.mdx"; import RegisterSplMint from "/snippets/setup/register-spl-mint.mdx"; import AgentSkillPayments from "/snippets/setup/agent-skill-payments.mdx"; +import PaymentsAiPrompt from "/snippets/ai-prompts/toolkits/payments.mdx"; 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 use the same stablecoins, just stored more efficiently. @@ -68,6 +69,9 @@ import AgentSkillPayments from "/snippets/setup/agent-skill-payments.mdx"; + + + ## Setup @@ -490,3 +494,9 @@ await unwrap(rpc, payer, splAta, owner, mint, amount); + + + + + + diff --git a/light-token/toolkits/for-privy.mdx b/light-token/toolkits/for-privy.mdx index 2c17f6ea..054b13c4 100644 --- a/light-token/toolkits/for-privy.mdx +++ b/light-token/toolkits/for-privy.mdx @@ -17,6 +17,7 @@ import BalancesNodejs from "/snippets/code-snippets/privy/balances/nodejs.mdx"; import BalancesReact from "/snippets/code-snippets/privy/balances/react.mdx"; import TransactionHistoryNodejs from "/snippets/code-snippets/privy/transaction-history/nodejs.mdx"; import TransactionHistoryReact from "/snippets/code-snippets/privy/transaction-history/react.mdx"; +import PrivyAiPrompt from "/snippets/ai-prompts/wallets/privy.mdx"; | Creation Cost | SPL | light-token | | :---------------- | :------------------ | :------------------- | @@ -69,6 +70,8 @@ Privy handles user authentication and wallet management. You build transactions + + ### Prerequisites @@ -97,7 +100,7 @@ const rpc = createRpc(RPC_ENDPOINT); ## Full code examples -Find complete examples on GitHub: [Node.js](https://github.com/Lightprotocol/examples-light-token/tree/main/privy/nodejs). +Find complete examples on GitHub: [Node.js](https://github.com/Lightprotocol/examples-light-token/tree/main/privy/nodejs) and [React](https://github.com/Lightprotocol/examples-light-token/tree/main/privy/react). @@ -188,3 +191,9 @@ Fetch light-token transaction history for an owner. + + + + + + diff --git a/light-token/toolkits/for-streaming-mints.mdx b/light-token/toolkits/for-streaming-mints.mdx index 542bf43d..3986df83 100644 --- a/light-token/toolkits/for-streaming-mints.mdx +++ b/light-token/toolkits/for-streaming-mints.mdx @@ -7,6 +7,7 @@ keywords: ["streaming mint accounts solana", "laserstream light mint", "grpc min import FindClosedAccounts from '/snippets/code-snippets/streaming/find-closed-accounts.mdx'; import AgentSkillStreaming from "/snippets/setup/agent-skill-streaming.mdx"; +import StreamingMintsAiPrompt from "/snippets/ai-prompts/streaming/mints.mdx"; | Event | Description | |:------|:------------| @@ -22,6 +23,9 @@ If you just need account lookups, use [`get_account_interface`](/light-token/def + + + ## Architecture Light mints are Solana accounts owned by the Light Token Program. The streaming @@ -254,3 +258,9 @@ pub struct AdditionalMetadata { href="/light-token/toolkits/for-streaming-tokens" horizontal /> + + + + + + diff --git a/light-token/toolkits/for-streaming-tokens.mdx b/light-token/toolkits/for-streaming-tokens.mdx index 7b4233eb..eb11290c 100644 --- a/light-token/toolkits/for-streaming-tokens.mdx +++ b/light-token/toolkits/for-streaming-tokens.mdx @@ -7,6 +7,7 @@ keywords: ["streaming token accounts solana", "laserstream light token", "grpc t import FindClosedAccounts from '/snippets/code-snippets/streaming/find-closed-accounts.mdx'; import AgentSkillStreaming from "/snippets/setup/agent-skill-streaming.mdx"; +import StreamingTokensAiPrompt from "/snippets/ai-prompts/streaming/tokens.mdx"; This guide is for teams building custom data pipelines (aggregators, market makers). @@ -15,6 +16,9 @@ If you just need account lookups, use [`get_account_interface`](/light-token/def + + + ## Architecture Light token accounts share the same base layout as SPL Token (165 bytes), so you can @@ -261,3 +265,9 @@ Source: [`light-token-interface`](https://github.com/Lightprotocol/light-protoco href="/light-token/toolkits/for-streaming-mints" horizontal /> + + + + + + diff --git a/light-token/toolkits/for-wallets.mdx b/light-token/toolkits/for-wallets.mdx index b02572e9..03745245 100644 --- a/light-token/toolkits/for-wallets.mdx +++ b/light-token/toolkits/for-wallets.mdx @@ -8,6 +8,7 @@ keywords: ["wallet infrastructure on solana", "scalable wallet infrastructure on import { CodeCompare } from "/snippets/jsx/code-compare.jsx"; import ToolkitsSetup from "/snippets/setup/toolkits-setup.mdx"; import AgentSkillPayments from "/snippets/setup/agent-skill-payments.mdx"; +import WalletsAiPrompt from "/snippets/ai-prompts/toolkits/wallets.mdx"; 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 hold and receive tokens of the same mints, just stored more efficiently. @@ -67,6 +68,9 @@ import AgentSkillPayments from "/snippets/setup/agent-skill-payments.mdx"; + + + ## Setup @@ -428,3 +432,9 @@ await unwrap(rpc, payer, splAta, owner, mint, amount); + + + + + + diff --git a/client-library/client-guide.mdx b/pda/compressed-pdas/guides/client-guide.mdx similarity index 98% rename from client-library/client-guide.mdx rename to pda/compressed-pdas/guides/client-guide.mdx index 945430ad..68358fd4 100644 --- a/client-library/client-guide.mdx +++ b/pda/compressed-pdas/guides/client-guide.mdx @@ -9,6 +9,7 @@ keywords: ["compressed pda client", "light protocol sdk"] import SystemAccountsList from '/snippets/accounts-list/compressed-pdas-system-accounts-list.mdx'; import TypescriptClient from '/snippets/code-snippets/create/typescript-client.mdx'; import RustClient from '/snippets/code-snippets/create/rust-client.mdx'; +import ClientGuideAiPrompt from '/snippets/ai-prompts/cpi-programs/client-guide.mdx';
@@ -107,6 +108,8 @@ import RustClient from '/snippets/code-snippets/create/rust-client.mdx'; # Get Started + + ## Setup @@ -1072,6 +1075,11 @@ let instruction = Instruction { + + + + + # Full Code Examples @@ -1101,7 +1109,7 @@ Find all [full code examples with Rust and TypeScript tests here](https://github - **burn** - Permanently delete a compressed account (it cannot be initialized again). -For help with debugging, see the [Error Cheatsheet](../resources/error-cheatsheet/) and [AskDevin](https://deepwiki.com/Lightprotocol/light-protocol/3.1-javascripttypescript-sdks). +For help with debugging, see the [Error Cheatsheet](/resources/error-cheatsheet) and [AskDevin](https://deepwiki.com/Lightprotocol/light-protocol/3.1-javascripttypescript-sdks). # Next Steps diff --git a/pda/compressed-pdas/guides/how-to-burn-compressed-accounts.mdx b/pda/compressed-pdas/guides/how-to-burn-compressed-accounts.mdx index 57176396..05b2a02f 100644 --- a/pda/compressed-pdas/guides/how-to-burn-compressed-accounts.mdx +++ b/pda/compressed-pdas/guides/how-to-burn-compressed-accounts.mdx @@ -9,6 +9,7 @@ import CompressedPdasSystemAccountsList from '/snippets/accounts-list/compressed import DevelopmentEnvironmentSetup from '/snippets/setup/development-environment-setup.mdx'; import AnchorProgram from '/snippets/code-snippets/burn/anchor-program.mdx'; import NativeProgram from '/snippets/code-snippets/burn/native-program.mdx'; +import CpiBurnAiPrompt from '/snippets/ai-prompts/cpi-programs/burn.mdx'; Compressed accounts are permanently burned via CPI to the Light System Program. @@ -38,6 +39,8 @@ Here is the complete flow to burn compressed accounts: + + @@ -237,6 +240,11 @@ LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, instruction_data.proof) * `invoke(light_cpi_accounts)` calls the Light System Program with `CpiAccounts`. + + + + + # Full Code Example @@ -275,7 +283,7 @@ Find the source code [here](https://github.com/Lightprotocol/program-examples/tr title="Build a client for your program" icon="chevron-right" color="#0066ff" - href="/client-library/client-guide" + href="/pda/compressed-pdas/guides/client-guide" horizontal /> + + @@ -243,6 +246,11 @@ LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, instruction_data.proof) * `invoke()` calls the Light System Program with `CpiAccounts`. + + + + + # Full Code Example @@ -282,7 +290,7 @@ Find the source code [here](https://github.com/Lightprotocol/program-examples/tr title="Build a client for your program" icon="chevron-right" color="#0066ff" - href="/client-library/client-guide" + href="/pda/compressed-pdas/guides/client-guide" horizontal /> + + @@ -385,6 +388,11 @@ LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, instruction_data.proof) * `invoke(light_cpi_accounts)` calls the Light System Program with `CpiAccounts.` + + + + + # Full Code Example @@ -423,7 +431,7 @@ Find the source code [here](https://github.com/Lightprotocol/program-examples/tr title="Build a client for your program" icon="chevron-right" color="#0066ff" - href="/client-library/client-guide" + href="/pda/compressed-pdas/guides/client-guide" horizontal /> + + + ## How It Works 1. Derives PDA from `["nullifier", id]` seeds (where `id` is your unique identifier, e.g. a nonce, uuid, hash of signature, etc.) @@ -196,4 +201,10 @@ Note that this is a reference implementation. Feel free to fork the program as y Questions or need support? [Telegram](https://t.me/swen_light) | [email](mailto:support@lightprotocol.com) | [Discord](https://discord.com/invite/7cJ8BhAXhu) - \ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts.mdx b/pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts.mdx index 971ff72c..a5776fda 100644 --- a/pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts.mdx +++ b/pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts.mdx @@ -9,6 +9,7 @@ import CompressedPdasSystemAccountsList from '/snippets/accounts-list/compressed import DevelopmentEnvironmentSetup from '/snippets/setup/development-environment-setup.mdx'; import AnchorProgram from '/snippets/code-snippets/reinit/anchor-program.mdx'; import NativeProgram from '/snippets/code-snippets/reinit/native-program.mdx'; +import CpiReinitAiPrompt from '/snippets/ai-prompts/cpi-programs/reinitialize.mdx'; Compressed accounts are reinitialized via CPI to the Light System Program. @@ -37,6 +38,8 @@ Here is the complete flow to reinitialize compressed accounts: + + @@ -229,6 +232,11 @@ LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, instruction_data.proof) * `invoke(light_cpi_accounts)` calls the Light System Program with `CpiAccounts`. + + + + + # Full Code Example @@ -267,7 +275,7 @@ Find the source code [here](https://github.com/Lightprotocol/program-examples/tr title="Build a client for your program" icon="chevron-right" color="#0066ff" - href="/client-library/client-guide" + href="/pda/compressed-pdas/guides/client-guide" horizontal /> + + @@ -246,6 +249,11 @@ LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, instruction_data.proof) * `invoke(light_cpi_accounts)` calls the Light System Program with `CpiAccounts`. + + + + + # Full Code Example @@ -284,7 +292,7 @@ Find the source code [here](https://github.com/Lightprotocol/program-examples/tr title="Build a client for your program" icon="chevron-right" color="#0066ff" - href="/client-library/client-guide" + href="/pda/compressed-pdas/guides/client-guide" horizontal /> diff --git a/pda/light-pda/overview.mdx b/pda/light-pda/overview.mdx index 4eb1a1e6..b2a00336 100644 --- a/pda/light-pda/overview.mdx +++ b/pda/light-pda/overview.mdx @@ -5,6 +5,7 @@ description: "Create Solana PDA accounts with sponsored rent-exemption and minim import FullCounterExample from '/snippets/code-snippets/light-token/counter/anchor-macro/full-example.mdx'; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; +import LightPdaAiPrompt from "/snippets/ai-prompts/anchor-programs/light-pda.mdx"; | Creation Cost | Regular PDA | Light-PDA | |------------------|----------------------|-----------------| @@ -25,6 +26,9 @@ Audit overhead is minimal as your program logic is mostly untouched. The rest is + + + ## Step 1: Dependencies ```toml @@ -143,6 +147,12 @@ pub struct CreateCounter<'info> { View counter example on Github: [counter](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter) + + + + + + --- ## How it works diff --git a/resources/sdks/client-development.mdx b/resources/sdks/client-development.mdx index a26c6ee7..820d8135 100644 --- a/resources/sdks/client-development.mdx +++ b/resources/sdks/client-development.mdx @@ -79,7 +79,7 @@ light-sdk = "0.16.0" title="Build your client with this guide." icon="chevron-right" color="#0066ff" - href="/client-library/client-guide" + href="/pda/compressed-pdas/guides/client-guide" horizontal > \ No newline at end of file diff --git a/scripts/copy-privy-snippets.sh b/scripts/copy-privy-snippets.sh index 3c368c54..0e91d602 100755 --- a/scripts/copy-privy-snippets.sh +++ b/scripts/copy-privy-snippets.sh @@ -1,21 +1,22 @@ #!/bin/bash -# Script to copy TypeScript code from Privy examples to docs/snippets/code-snippets/privy -# Wraps each file in typescript markdown code blocks +# Script to copy TypeScript code from Light Token Privy examples to docs snippets. +# Source: examples-light-token/privy/{nodejs,react} +# Output: snippets/code-snippets/privy/{operation}/{nodejs,react}.mdx -NODEJS_SRC="/home/tilo/Workspace/examples-zk-compression/privy/nodejs-privy-compressed/src" -REACT_SRC="/home/tilo/Workspace/examples-zk-compression/privy/react-privy-compressed/src/hooks" -SNIPPETS_DIR="/home/tilo/Workspace/docs/snippets/code-snippets/privy" +NODEJS_SRC="/home/tilo/Workspace/examples-light-token/privy/nodejs/src" +REACT_SRC="/home/tilo/Workspace/examples-light-token/privy/react/src/hooks" +SNIPPETS_DIR="/home/tilo/Workspace/docs-main-reorder/snippets/code-snippets/privy" # Operations to process -OPERATIONS=("transfer" "compress" "decompress" "balances" "transaction-history") +OPERATIONS=("transfer" "wrap" "unwrap" "balances" "transaction-history") -# Function to wrap TypeScript code in markdown +# Wrap TypeScript code in markdown code block, stripping "// --- main ---" runner section wrap_typescript() { local input_file="$1" local output_file="$2" echo '```typescript' > "$output_file" - cat "$input_file" >> "$output_file" + sed '/^\/\/ --- main ---$/,$d' "$input_file" >> "$output_file" echo '```' >> "$output_file" echo "Created: $output_file" } @@ -28,8 +29,8 @@ done # Process Node.js operations echo "Processing Node.js operations..." wrap_typescript "$NODEJS_SRC/transfer.ts" "$SNIPPETS_DIR/transfer/nodejs.mdx" -wrap_typescript "$NODEJS_SRC/compress.ts" "$SNIPPETS_DIR/compress/nodejs.mdx" -wrap_typescript "$NODEJS_SRC/decompress.ts" "$SNIPPETS_DIR/decompress/nodejs.mdx" +wrap_typescript "$NODEJS_SRC/wrap.ts" "$SNIPPETS_DIR/wrap/nodejs.mdx" +wrap_typescript "$NODEJS_SRC/unwrap.ts" "$SNIPPETS_DIR/unwrap/nodejs.mdx" wrap_typescript "$NODEJS_SRC/balances.ts" "$SNIPPETS_DIR/balances/nodejs.mdx" wrap_typescript "$NODEJS_SRC/get-transaction-history.ts" "$SNIPPETS_DIR/transaction-history/nodejs.mdx" @@ -37,11 +38,17 @@ wrap_typescript "$NODEJS_SRC/get-transaction-history.ts" "$SNIPPETS_DIR/transact echo "" echo "Processing React operations..." wrap_typescript "$REACT_SRC/useTransfer.ts" "$SNIPPETS_DIR/transfer/react.mdx" -wrap_typescript "$REACT_SRC/useCompress.ts" "$SNIPPETS_DIR/compress/react.mdx" -wrap_typescript "$REACT_SRC/useDecompress.ts" "$SNIPPETS_DIR/decompress/react.mdx" -wrap_typescript "$REACT_SRC/useCompressedBalances.ts" "$SNIPPETS_DIR/balances/react.mdx" +wrap_typescript "$REACT_SRC/useWrap.ts" "$SNIPPETS_DIR/wrap/react.mdx" +wrap_typescript "$REACT_SRC/useUnwrap.ts" "$SNIPPETS_DIR/unwrap/react.mdx" +wrap_typescript "$REACT_SRC/useLightTokenBalances.ts" "$SNIPPETS_DIR/balances/react.mdx" wrap_typescript "$REACT_SRC/useTransactionHistory.ts" "$SNIPPETS_DIR/transaction-history/react.mdx" +# Copy shared React helper +echo "" +echo "Processing shared helpers..." +mkdir -p "$SNIPPETS_DIR/helpers" +wrap_typescript "$REACT_SRC/signAndSendBatches.ts" "$SNIPPETS_DIR/helpers/sign-and-send-batches.mdx" + echo "" echo "Done! Created snippets in: $SNIPPETS_DIR" echo "" diff --git a/snippets/ai-prompts/anchor-program-template.mdx b/snippets/ai-prompts/anchor-program-template.mdx new file mode 100644 index 00000000..b4949b47 --- /dev/null +++ b/snippets/ai-prompts/anchor-program-template.mdx @@ -0,0 +1,57 @@ +```text +--- +description: {{OPERATION_DESCRIPTION}} +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## {{OPERATION_DESCRIPTION}} + +Context: +- Guide: https://zkcompression.com/{{PAGE_PATH}} +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: {{CRATES}} +{{EXTRA_REFS}} + +Key macros/APIs: {{KEY_MACROS}} + +### 1. Index project +- Grep `{{INDEX_GREP}}` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: existing program module, account structs, PDA seeds, token accounts, init instructions +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, migrate existing program to rent-free, add rent-free accounts to specific instructions) +- AskUserQuestion: which account types need to be rent-free? (PDAs, token accounts, ATAs, mints) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan +- Follow the guide's step order: {{STEP_ORDER}} +- Identify which existing structs need changes (CompressionInfo field, LightAccount derive, etc.) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add {{DEPS}}` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `{{BUILD_CMD}}` +- Bash `{{TEST_CMD}}` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/anchor-programs/defi-anchor.mdx b/snippets/ai-prompts/anchor-programs/defi-anchor.mdx new file mode 100644 index 00000000..1bcce1db --- /dev/null +++ b/snippets/ai-prompts/anchor-programs/defi-anchor.mdx @@ -0,0 +1,57 @@ +```text +--- +description: Add rent-free accounts to an Anchor DeFi program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add rent-free accounts to an Anchor DeFi program + +Context: +- Guide: https://zkcompression.com/light-token/defi/programs +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-sdk (features: anchor, v2, cpi-context), light-sdk-macros, light-token (features: anchor), light-anchor-spl +- AMM reference: https://github.com/Lightprotocol/cp-swap-reference + +Key macros/APIs: #[light_program], LightAccount, LightAccounts, #[light_account(init)], CompressionInfo + +### 1. Index project +- Grep `#\[program\]|anchor_lang|Account<|Accounts|InitSpace|seeds|init|payer` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: existing program module, account structs, PDA seeds, token accounts, init instructions +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, migrate existing program to rent-free, add rent-free accounts to specific instructions) +- AskUserQuestion: which account types need to be rent-free? (PDAs, token accounts, ATAs, mints) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan +- Follow the guide's step order: Dependencies → State Struct → Program Module → Accounts Struct → Instructions +- Identify which existing structs need changes (CompressionInfo field, LightAccount derive, etc.) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-sdk@0.19 --features anchor,v2,cpi-context` and `cargo add light-sdk-macros@0.19` and `cargo add light-token@0.4 --features anchor` and `cargo add light-anchor-spl@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/anchor-programs/defi-pinocchio.mdx b/snippets/ai-prompts/anchor-programs/defi-pinocchio.mdx new file mode 100644 index 00000000..568b3ec3 --- /dev/null +++ b/snippets/ai-prompts/anchor-programs/defi-pinocchio.mdx @@ -0,0 +1,57 @@ +```text +--- +description: Add rent-free accounts to a Pinocchio DeFi program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add rent-free accounts to a Pinocchio DeFi program + +Context: +- Guide: https://zkcompression.com/light-token/defi/programs-pinocchio +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-account-pinocchio (features: token, std), light-token-pinocchio, pinocchio +- Swap reference: https://github.com/Lightprotocol/examples-light-token/tree/simplify-trait/pinocchio/swap + +Key macros/APIs: LightPinocchioAccount, LightProgramPinocchio, CreateTokenAccountCpi, derive_light_cpi_signer! + +### 1. Index project +- Grep `pinocchio|entrypoint!|ProgramError|AccountInfo|process_instruction` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: existing program module, account structs, PDA seeds, token accounts, init instructions +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, migrate existing program to rent-free, add rent-free accounts to specific instructions) +- AskUserQuestion: which account types need to be rent-free? (PDAs, token accounts, ATAs, mints) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan +- Follow the guide's step order: Dependencies → State Struct → Program Enum → Entrypoint → Init Handler +- Identify which existing structs need changes (CompressionInfo field, LightPinocchioAccount derive, etc.) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-account-pinocchio@0.20 --features token,std` and `cargo add light-token-pinocchio@0.20` and `cargo add pinocchio@0.9` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo build-sbf` +- Bash `cargo test-sbf` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/anchor-programs/light-pda.mdx b/snippets/ai-prompts/anchor-programs/light-pda.mdx new file mode 100644 index 00000000..8cc9c94e --- /dev/null +++ b/snippets/ai-prompts/anchor-programs/light-pda.mdx @@ -0,0 +1,57 @@ +```text +--- +description: Add rent-free PDAs to an Anchor program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add rent-free PDAs to an Anchor program + +Context: +- Guide: https://zkcompression.com/pda/light-pda/overview +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-account (features: anchor), light-sdk (features: anchor, v2, cpi-context) +- Counter example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter + +Key macros/APIs: #[light_program], LightAccount, LightAccounts, #[light_account(init)], CompressionInfo, CreateAccountsProof + +### 1. Index project +- Grep `#\[program\]|anchor_lang|Account<|Accounts|InitSpace|seeds|init|payer` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: existing program module, account structs, PDA seeds, token accounts, init instructions +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, migrate existing program to rent-free, add rent-free accounts to specific instructions) +- AskUserQuestion: which account types need to be rent-free? (PDAs, token accounts, ATAs, mints) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan +- Follow the guide's step order: Dependencies → State Struct → Program Module → Accounts Struct +- Identify which existing structs need changes (CompressionInfo field, LightAccount derive, etc.) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-account@0.20 --features anchor` and `cargo add light-sdk@0.20 --features anchor,v2,cpi-context` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/cpi-program-template.mdx b/snippets/ai-prompts/cpi-program-template.mdx new file mode 100644 index 00000000..f9cf32cc --- /dev/null +++ b/snippets/ai-prompts/cpi-program-template.mdx @@ -0,0 +1,57 @@ +```text +--- +description: {{OPERATION_DESCRIPTION}} +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## {{OPERATION_DESCRIPTION}} + +Context: +- Guide: https://zkcompression.com/pda/compressed-pdas/guides/{{PAGE_SLUG}} +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-sdk (LightAccount, CpiAccounts, LightSystemProgramCpi, derive_light_cpi_signer!) +{{EXTRA_REFS}} + +Key SDK API: {{KEY_API}} + +### 1. Index project +- Grep `declare_id|#\[program\]|entrypoint!|Pubkey|AccountInfo{{EXTRA_GREP}}` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, framework (Anchor or native) +- Read Cargo.toml — note existing dependencies and Solana SDK version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review both Anchor and Native Rust code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, add {{OP_SHORT}} to existing program, migrate from regular accounts) +- AskUserQuestion: Anchor or Native Rust framework? +- AskUserQuestion: does the program already have compressed account instructions, or is this the first one? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Dependencies → Constants → Account Struct → Instruction Data → {{OP_SPECIFIC_STEPS}} → Light System Program CPI +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps: Bash `cargo add light-sdk@0.16` (add `anchor_lang@0.31` for Anchor or `solana-program@2.2` + `borsh@0.10` for Native Rust) +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo build-sbf` or `anchor build` +- Bash `cargo test-sbf` or `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/cpi-programs/burn.mdx b/snippets/ai-prompts/cpi-programs/burn.mdx new file mode 100644 index 00000000..02d70ca7 --- /dev/null +++ b/snippets/ai-prompts/cpi-programs/burn.mdx @@ -0,0 +1,58 @@ +```text +--- +description: Build a program that permanently burns compressed accounts +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Build a program that permanently burns compressed accounts + +Context: +- Guide: https://zkcompression.com/pda/compressed-pdas/guides/how-to-burn-compressed-accounts +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-sdk (LightAccount, CpiAccounts, LightSystemProgramCpi, derive_light_cpi_signer!) +- Anchor example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/burn +- Native Rust example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/burn + +Key SDK API: LightAccount::new_burn() + +### 1. Index project +- Grep `declare_id|#\[program\]|entrypoint!|Pubkey|AccountInfo|burn|destroy|permanent` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, framework (Anchor or native) +- Read Cargo.toml — note existing dependencies and Solana SDK version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review both Anchor and Native Rust code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, add account burn to existing program, migrate from regular accounts) +- AskUserQuestion: Anchor or Native Rust framework? +- AskUserQuestion: does the program already have compressed account instructions, or is this the first one? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Dependencies → Constants → Account Struct → Instruction Data → Burn Compressed Account → Light System Program CPI +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps: Bash `cargo add light-sdk@0.16` (add `anchor_lang@0.31` for Anchor or `solana-program@2.2` + `borsh@0.10` for Native Rust) +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo build-sbf` or `anchor build` +- Bash `cargo test-sbf` or `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/cpi-programs/client-guide.mdx b/snippets/ai-prompts/cpi-programs/client-guide.mdx new file mode 100644 index 00000000..3a6a0bc5 --- /dev/null +++ b/snippets/ai-prompts/cpi-programs/client-guide.mdx @@ -0,0 +1,63 @@ +```text +--- +description: Write client code to interact with compressed PDA programs +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Write client code to interact with compressed PDA programs + +Context: +- Guide: https://zkcompression.com/pda/compressed-pdas/guides/client-guide +- Skills and resources index: https://zkcompression.com/skill.md +- TS packages: @lightprotocol/stateless.js, @lightprotocol/compressed-token, @solana/web3.js +- Rust crates: light-client, light-sdk +- TS example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/create/tests +- Rust example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/create/programs/create/tests +- All operations: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor + +Key APIs: +- TS: createRpc(), deriveAddressSeedV2(), deriveAddressV2(), getValidityProofV0(), PackedAccounts, SystemAccountMetaConfig, getStateTreeInfos(), selectStateTreeInfo() +- Rust: LightClientConfig, LightClient, derive_address(), get_validity_proof(), PackedAccounts, SystemAccountMetaConfig, get_random_state_tree_info() + +### 1. Index project +- Grep `@lightprotocol|stateless\.js|createRpc|deriveAddress|getValidityProof|PackedAccounts|light_client|light_sdk|derive_address|get_validity_proof` across src/ +- Glob `**/*.ts` and `**/*.rs` for project structure +- Identify: RPC setup, existing compressed account operations, program ID references +- Check package.json or Cargo.toml for existing light-* dependencies +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — review both TypeScript and Rust code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: TypeScript or Rust? +- AskUserQuestion: what is the goal? (new client from scratch, add client calls to existing project, migrate from regular accounts) +- AskUserQuestion: which operations? (create only, full CRUD, specific subset like create + update) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Setup → Address derivation → Validity proof → PackedAccounts → Instruction data → Build instruction → Send transaction +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- For TypeScript: Bash `npm install @lightprotocol/stateless.js @lightprotocol/compressed-token @solana/web3.js` +- For Rust: Bash `cargo add light-client@0.16 light-sdk@0.16` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- TypeScript: Bash `tsc --noEmit` + run existing test suite if present +- Rust: Bash `cargo check` + `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/cpi-programs/close.mdx b/snippets/ai-prompts/cpi-programs/close.mdx new file mode 100644 index 00000000..e7fcabdf --- /dev/null +++ b/snippets/ai-prompts/cpi-programs/close.mdx @@ -0,0 +1,58 @@ +```text +--- +description: Build a program that closes compressed accounts +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Build a program that closes compressed accounts + +Context: +- Guide: https://zkcompression.com/pda/compressed-pdas/guides/how-to-close-compressed-accounts +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-sdk (LightAccount, CpiAccounts, LightSystemProgramCpi, derive_light_cpi_signer!) +- Anchor example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/close +- Native Rust example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/close + +Key SDK API: LightAccount::new_close() + +### 1. Index project +- Grep `declare_id|#\[program\]|entrypoint!|Pubkey|AccountInfo|close|delete|remove` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, framework (Anchor or native) +- Read Cargo.toml — note existing dependencies and Solana SDK version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review both Anchor and Native Rust code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, add account close to existing program, migrate from regular accounts) +- AskUserQuestion: Anchor or Native Rust framework? +- AskUserQuestion: does the program already have compressed account instructions, or is this the first one? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Dependencies → Constants → Account Struct → Instruction Data → Close Compressed Account → Light System Program CPI +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps: Bash `cargo add light-sdk@0.16` (add `anchor_lang@0.31` for Anchor or `solana-program@2.2` + `borsh@0.10` for Native Rust) +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo build-sbf` or `anchor build` +- Bash `cargo test-sbf` or `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/cpi-programs/create.mdx b/snippets/ai-prompts/cpi-programs/create.mdx new file mode 100644 index 00000000..90f3ac3d --- /dev/null +++ b/snippets/ai-prompts/cpi-programs/create.mdx @@ -0,0 +1,58 @@ +```text +--- +description: Build a program that creates compressed accounts with addresses +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Build a program that creates compressed accounts with addresses + +Context: +- Guide: https://zkcompression.com/pda/compressed-pdas/guides/how-to-create-compressed-accounts +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-sdk (LightAccount, CpiAccounts, LightSystemProgramCpi, derive_light_cpi_signer!) +- Anchor example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/create +- Native Rust example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/create + +Key SDK API: LightAccount::new_init(), derive_address() + +### 1. Index project +- Grep `declare_id|#\[program\]|entrypoint!|Pubkey|AccountInfo|seeds|init|payer|space` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, framework (Anchor or native) +- Read Cargo.toml — note existing dependencies and Solana SDK version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review both Anchor and Native Rust code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, add account creation to existing program, migrate from regular accounts) +- AskUserQuestion: Anchor or Native Rust framework? +- AskUserQuestion: does the program already have compressed account instructions, or is this the first one? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Dependencies → Constants → Account Struct → Instruction Data → Derive Address → Address Tree Check → Initialize Account → Light System Program CPI +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps: Bash `cargo add light-sdk@0.16` (add `anchor_lang@0.31` for Anchor or `solana-program@2.2` + `borsh@0.10` for Native Rust) +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo build-sbf` or `anchor build` +- Bash `cargo test-sbf` or `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/cpi-programs/reinitialize.mdx b/snippets/ai-prompts/cpi-programs/reinitialize.mdx new file mode 100644 index 00000000..efc3124d --- /dev/null +++ b/snippets/ai-prompts/cpi-programs/reinitialize.mdx @@ -0,0 +1,58 @@ +```text +--- +description: Build a program that reinitializes closed compressed accounts +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Build a program that reinitializes closed compressed accounts + +Context: +- Guide: https://zkcompression.com/pda/compressed-pdas/guides/how-to-reinitialize-compressed-accounts +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-sdk (LightAccount, CpiAccounts, LightSystemProgramCpi, derive_light_cpi_signer!) +- Anchor example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/reinit +- Native Rust example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/reinit + +Key SDK API: LightAccount::new_empty() + +### 1. Index project +- Grep `declare_id|#\[program\]|entrypoint!|Pubkey|AccountInfo|reinit|empty|reset` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, framework (Anchor or native) +- Read Cargo.toml — note existing dependencies and Solana SDK version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review both Anchor and Native Rust code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, add account reinitialization to existing program, migrate from regular accounts) +- AskUserQuestion: Anchor or Native Rust framework? +- AskUserQuestion: does the program already have compressed account instructions, or is this the first one? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Dependencies → Constants → Account Struct → Instruction Data → Reinitialize Closed Account → Light System Program CPI +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps: Bash `cargo add light-sdk@0.16` (add `anchor_lang@0.31` for Anchor or `solana-program@2.2` + `borsh@0.10` for Native Rust) +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo build-sbf` or `anchor build` +- Bash `cargo test-sbf` or `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/cpi-programs/update.mdx b/snippets/ai-prompts/cpi-programs/update.mdx new file mode 100644 index 00000000..32210dd6 --- /dev/null +++ b/snippets/ai-prompts/cpi-programs/update.mdx @@ -0,0 +1,58 @@ +```text +--- +description: Build a program that updates compressed accounts +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Build a program that updates compressed accounts + +Context: +- Guide: https://zkcompression.com/pda/compressed-pdas/guides/how-to-update-compressed-accounts +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-sdk (LightAccount, CpiAccounts, LightSystemProgramCpi, derive_light_cpi_signer!) +- Anchor example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/anchor/update +- Native Rust example: https://github.com/Lightprotocol/program-examples/tree/main/basic-operations/native/programs/update + +Key SDK API: LightAccount::new_mut() + +### 1. Index project +- Grep `declare_id|#\[program\]|entrypoint!|Pubkey|AccountInfo|mut|update|modify` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, framework (Anchor or native) +- Read Cargo.toml — note existing dependencies and Solana SDK version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review both Anchor and Native Rust code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, add account update to existing program, migrate from regular accounts) +- AskUserQuestion: Anchor or Native Rust framework? +- AskUserQuestion: does the program already have compressed account instructions, or is this the first one? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Dependencies → Constants → Account Struct → Instruction Data → Update Compressed Account → Light System Program CPI +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps: Bash `cargo add light-sdk@0.16` (add `anchor_lang@0.31` for Anchor or `solana-program@2.2` + `borsh@0.10` for Native Rust) +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo build-sbf` or `anchor build` +- Bash `cargo test-sbf` or `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/defi/routers.mdx b/snippets/ai-prompts/defi/routers.mdx new file mode 100644 index 00000000..74454cb2 --- /dev/null +++ b/snippets/ai-prompts/defi/routers.mdx @@ -0,0 +1,61 @@ +```text +--- +description: Integrate rent-free AMM markets into a router or aggregator +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Integrate rent-free AMM markets into a router or aggregator + +Context: +- Guide: https://zkcompression.com/light-token/defi/routers +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-client (features: v2) — provides AccountInterface, LightProgramInterface, create_load_instructions +- AMM reference: https://github.com/Lightprotocol/cp-swap-reference +- Streaming guides: https://zkcompression.com/light-token/toolkits/for-streaming-tokens + +Key APIs: create_load_instructions(), LightProgramInterface trait, get_account_interface(), get_multiple_account_interfaces(), is_cold() + +### 1. Index project +- Grep `LightProgramInterface|create_load_instructions|AccountInterface|is_cold|get_account_interface|swap|amm|router|aggregator` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: existing routing/quoting logic, account caching, swap instruction building, streaming setup +- Read Cargo.toml — note existing dependencies and light-client version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (add cold market support to existing router, build new router with rent-free market support, integrate a specific AMM SDK) +- AskUserQuestion: does the project already stream account updates, or does it fetch at swap time? +- AskUserQuestion: does the project use Jito bundles for multi-transaction swaps? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan +- Follow the guide's progression: Cold Account Cache → Detecting Cold Accounts → Building Swap Transactions with Load Instructions +- If streaming: add account + transaction subscriptions for the Light Token Program +- If fetch-at-swap-time: add get_multiple_account_interfaces + is_cold() check before building swap tx +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-client@0.19 --features v2` +- Add AMM SDK dependency per the approved plan +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/approve-revoke.mdx b/snippets/ai-prompts/program-cookbook/approve-revoke.mdx new file mode 100644 index 00000000..8533a5b7 --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/approve-revoke.mdx @@ -0,0 +1,57 @@ +```text +--- +description: Add approve and revoke CPI to an Anchor program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add approve and revoke CPI to an Anchor program + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/approve-revoke +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-token (ApproveCpi, RevokeCpi) +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/approve + +Key CPI structs: `light_token::instruction::ApproveCpi`, `light_token::instruction::RevokeCpi` + +### 1. Index project +- Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|approve|revoke|delegate` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, delegate accounts +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review both Approve and Revoke CPI code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (add approve/revoke to existing program, new program from scratch, migrate from SPL approve/revoke) +- AskUserQuestion: should the owner be an external signer or a PDA? (determines invoke vs invoke_signed) +- AskUserQuestion: do you need both approve and revoke, or just one? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Build ApproveCpi/RevokeCpi structs → call .invoke() or .invoke_signed() +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/burn.mdx b/snippets/ai-prompts/program-cookbook/burn.mdx new file mode 100644 index 00000000..a784443f --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/burn.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Add burn CPI to an Anchor program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add burn CPI to an Anchor program + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/burn +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-token (BurnCpi) +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/burn + +Key CPI struct: `light_token::instruction::BurnCpi` + +### 1. Index project +- Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|burn|destroy|supply` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, token accounts +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review the Program tab CPI code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (add burn to existing program, new program from scratch, migrate from SPL burn) +- AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Build BurnCpi struct → call .invoke() or .invoke_signed() +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/close-token-account.mdx b/snippets/ai-prompts/program-cookbook/close-token-account.mdx new file mode 100644 index 00000000..84400a61 --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/close-token-account.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Add close-account CPI to an Anchor program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add close-account CPI to an Anchor program + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/close-token-account +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-token (CloseAccountCpi) +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/close + +Key CPI struct: `light_token::instruction::CloseAccountCpi` + +### 1. Index project +- Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|close|destination|rent` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, token accounts +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review the Program tab CPI code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (add close-account to existing program, new program from scratch, migrate from SPL close_account) +- AskUserQuestion: should the owner be an external signer or a PDA? (determines invoke vs invoke_signed) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Build CloseAccountCpi struct → call .invoke() or .invoke_signed() +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/create-ata-cpi.mdx b/snippets/ai-prompts/program-cookbook/create-ata-cpi.mdx new file mode 100644 index 00000000..38890159 --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/create-ata-cpi.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Add create-ATA CPI to an Anchor program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add create-ATA CPI to an Anchor program + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/create-ata +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-token (CreateAssociatedAccountCpi) +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-associated-token-account + +Key CPI struct: `light_token::instruction::CreateAssociatedAccountCpi` + +### 1. Index project +- Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|ata|associated|owner|mint` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, ATA derivation +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review the CPI tab under Program: ATA creation with .rent_free() chain +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (add create-ATA to existing program, new program from scratch, migrate from SPL create_associated_token_account) +- AskUserQuestion: should the payer be an external signer or a PDA? (determines invoke vs invoke_signed) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Build CreateAssociatedAccountCpi → .rent_free() → .invoke() or .invoke_signed() +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/create-ata-macros.mdx b/snippets/ai-prompts/program-cookbook/create-ata-macros.mdx new file mode 100644 index 00000000..dc6c0870 --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/create-ata-macros.mdx @@ -0,0 +1,55 @@ +```text +--- +description: Create a rent-free ATA with Anchor macros +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Create a rent-free ATA with Anchor macros + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/create-ata +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-sdk, light-sdk-macros, light-compressible, anchor-lang +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-associated-token-account + +Key macros: `#[light_program]`, `LightAccounts`, `#[light_account(init, associated_token::...)]` + +### 1. Index project +- Grep `#\[program\]|anchor_lang|Account<|Accounts|seeds|init|payer|ata|associated` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: existing program module, account structs, ATA patterns +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review the Anchor Macros tab under Program +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, add rent-free ATA to existing program, migrate from SPL create_associated_token_account) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan +- Follow the guide's step order: Dependencies → Program Module (#[light_program]) → Accounts Struct (#[light_account(init, associated_token::...)]) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-sdk@0.18 --features anchor,v2,cpi-context` and `cargo add light-sdk-macros@0.18 light-compressible@0.1 anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/create-mint-cpi.mdx b/snippets/ai-prompts/program-cookbook/create-mint-cpi.mdx new file mode 100644 index 00000000..34a58eff --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/create-mint-cpi.mdx @@ -0,0 +1,57 @@ +```text +--- +description: Add create-mint CPI to an Anchor program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add create-mint CPI to an Anchor program + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/create-mint +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-token (CreateMintCpi, CreateMintParams, SystemAccountInfos) +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-mint + +Key CPI struct: `light_token::instruction::CreateMintCpi` + +### 1. Index project +- Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|mint|decimals|authority|metadata` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, mint seeds +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review the CPI tab under Program: token metadata config, mint params, system accounts, invoke patterns +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (add create-mint to existing program, new program from scratch, migrate from SPL create_mint) +- AskUserQuestion: should the mint seed be an external keypair or a PDA? (determines invoke vs invoke_signed) +- AskUserQuestion: do you need token metadata (name, symbol, uri)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Configure Token Metadata → Configure Mint Params → System Accounts → Build CPI and invoke +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/create-mint-macros.mdx b/snippets/ai-prompts/program-cookbook/create-mint-macros.mdx new file mode 100644 index 00000000..4721c6f4 --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/create-mint-macros.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Create a rent-free mint with Anchor macros +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Create a rent-free mint with Anchor macros + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/create-mint +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-sdk, light-sdk-macros, light-compressible, anchor-lang +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-mint + +Key macros: `#[light_program]`, `LightAccounts`, `#[light_account(init, mint::...)]` + +### 1. Index project +- Grep `#\[program\]|anchor_lang|Account<|Accounts|seeds|init|payer|mint` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: existing program module, account structs, mint patterns, PDA seeds +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review the Anchor Macros tab under Program +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, add rent-free mint to existing program, migrate from SPL create_mint) +- AskUserQuestion: do you need token metadata (name, symbol, uri)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan +- Follow the guide's step order: Dependencies → Program Module (#[light_program]) → Accounts Struct (#[light_account(init, mint::...)]) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-sdk@0.18 --features anchor,v2,cpi-context` and `cargo add light-sdk-macros@0.18 light-compressible@0.1 anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/create-token-account-cpi.mdx b/snippets/ai-prompts/program-cookbook/create-token-account-cpi.mdx new file mode 100644 index 00000000..dc1c2c9f --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/create-token-account-cpi.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Add create-token-account CPI to an Anchor program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add create-token-account CPI to an Anchor program + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/create-token-account +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-token (CreateTokenAccountCpi) +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/create-token-account + +Key CPI struct: `light_token::instruction::CreateTokenAccountCpi` + +### 1. Index project +- Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|token_account|vault|owner|mint` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, vault/token account patterns +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review the CPI tab under Program: token account creation with .rent_free() chain +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (add create-token-account to existing program, new program from scratch, migrate from SPL token account init) +- AskUserQuestion: should the payer be an external signer or a PDA? (determines invoke vs invoke_signed) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Build CreateTokenAccountCpi → .rent_free() → .invoke() or .invoke_signed() +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/create-token-account-macros.mdx b/snippets/ai-prompts/program-cookbook/create-token-account-macros.mdx new file mode 100644 index 00000000..b8bb3f2d --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/create-token-account-macros.mdx @@ -0,0 +1,55 @@ +```text +--- +description: Create a rent-free token account with Anchor macros +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Create a rent-free token account with Anchor macros + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/create-token-account +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-sdk, light-sdk-macros, light-compressible, anchor-lang +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/create-token-account + +Key macros: `#[light_program]`, `LightAccounts`, `#[light_account(init, token::...)]` + +### 1. Index project +- Grep `#\[program\]|anchor_lang|Account<|Accounts|seeds|init|payer|vault|token_account` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: existing program module, account structs, vault/token account patterns +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review the Anchor Macros tab under Program +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new program from scratch, add rent-free token account to existing program, migrate from SPL token account init) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan +- Follow the guide's step order: Dependencies → Program Module (#[light_program]) → Accounts Struct (#[light_account(init, token::...)]) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-sdk@0.18 --features anchor,v2,cpi-context` and `cargo add light-sdk-macros@0.18 light-compressible@0.1 anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/freeze-thaw.mdx b/snippets/ai-prompts/program-cookbook/freeze-thaw.mdx new file mode 100644 index 00000000..7ed90dea --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/freeze-thaw.mdx @@ -0,0 +1,57 @@ +```text +--- +description: Add freeze and thaw CPI to an Anchor program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add freeze and thaw CPI to an Anchor program + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/freeze-thaw +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-token (FreezeCpi, ThawCpi) +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/freeze + +Key CPI structs: `light_token::instruction::FreezeCpi`, `light_token::instruction::ThawCpi` + +### 1. Index project +- Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|freeze|thaw|authority` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, freeze authority +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review both Freeze and Thaw CPI code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (add freeze/thaw to existing program, new program from scratch, migrate from SPL freeze/thaw) +- AskUserQuestion: should the freeze authority be an external signer or a PDA? (determines invoke vs invoke_signed) +- AskUserQuestion: do you need both freeze and thaw, or just one? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Build FreezeCpi/ThawCpi structs → call .invoke() or .invoke_signed() +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/mint-to.mdx b/snippets/ai-prompts/program-cookbook/mint-to.mdx new file mode 100644 index 00000000..bc1064cb --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/mint-to.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Add mint-to CPI to an Anchor program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add mint-to CPI to an Anchor program + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/mint-to +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-token (MintToCpi) +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/mint-to + +Key CPI struct: `light_token::instruction::MintToCpi` + +### 1. Index project +- Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|mint|supply|amount` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, mint accounts +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review the Program tab CPI code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (add mint-to to existing program, new program from scratch, migrate from SPL mint_to) +- AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Build MintToCpi struct → call .invoke() or .invoke_signed() +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/transfer-checked.mdx b/snippets/ai-prompts/program-cookbook/transfer-checked.mdx new file mode 100644 index 00000000..62c9bb7d --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/transfer-checked.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Add transfer-checked CPI to an Anchor program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add transfer-checked CPI to an Anchor program + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/transfer-checked +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-token (TransferCheckedCpi) +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/transfer-checked + +Key CPI struct: `light_token::instruction::TransferCheckedCpi` + +### 1. Index project +- Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|transfer|decimals|amount` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, token accounts +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review the Program tab CPI code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (add transfer-checked to existing program, new program from scratch, migrate from SPL transfer_checked) +- AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Build TransferCheckedCpi struct → call .invoke() or .invoke_signed() +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/program-cookbook/transfer-interface.mdx b/snippets/ai-prompts/program-cookbook/transfer-interface.mdx new file mode 100644 index 00000000..236a9625 --- /dev/null +++ b/snippets/ai-prompts/program-cookbook/transfer-interface.mdx @@ -0,0 +1,57 @@ +```text +--- +description: Add transfer-interface CPI to an Anchor program +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add transfer-interface CPI to an Anchor program + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/transfer-interface +- Skills and resources index: https://zkcompression.com/skill.md +- Crate: light-token (TransferInterfaceCpi) +- Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/transfer-interface + +Key CPI struct: `light_token::instruction::TransferInterfaceCpi` + +### 1. Index project +- Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|transfer|decimals|interface` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: program ID, existing instructions, account structs, token accounts +- Read Cargo.toml — note existing dependencies and framework version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — review the Program tab CPI code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (add transfer-interface to existing program, new program from scratch, migrate from SPL transfer) +- AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed) +- AskUserQuestion: which token types will be transferred? (SPL, Token 2022, Light Token, or all via interface) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's step order: Build TransferInterfaceCpi → call .invoke() or .invoke_signed() +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token anchor-lang@0.31` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `anchor build` +- Bash `anchor test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-cookbook/approve-revoke.mdx b/snippets/ai-prompts/rust-cookbook/approve-revoke.mdx new file mode 100644 index 00000000..2bec95b8 --- /dev/null +++ b/snippets/ai-prompts/rust-cookbook/approve-revoke.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Approve and revoke token delegates +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Approve and revoke token delegates + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/approve-revoke +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) + +SPL equivalent: spl_token::instruction::approve / revoke → Light Token: Approve / Revoke + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|Approve|Revoke|delegate` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for delegation +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have delegation operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-cookbook/burn.mdx b/snippets/ai-prompts/rust-cookbook/burn.mdx new file mode 100644 index 00000000..21a50927 --- /dev/null +++ b/snippets/ai-prompts/rust-cookbook/burn.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Burn Light Tokens +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Burn Light Tokens + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/burn +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) + +SPL equivalent: spl_token::instruction::burn → Light Token: Burn + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|Burn|burn` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for burn +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have burn operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-cookbook/close-token-account.mdx b/snippets/ai-prompts/rust-cookbook/close-token-account.mdx new file mode 100644 index 00000000..8947634c --- /dev/null +++ b/snippets/ai-prompts/rust-cookbook/close-token-account.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Close Light Token account +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Close Light Token account + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/close-token-account +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) + +SPL equivalent: spl_token::instruction::close_account → Light Token: CloseAccount + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|CloseAccount|close_account` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for close account +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have close operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-cookbook/create-ata.mdx b/snippets/ai-prompts/rust-cookbook/create-ata.mdx new file mode 100644 index 00000000..3223932e --- /dev/null +++ b/snippets/ai-prompts/rust-cookbook/create-ata.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Create rent-free associated token account +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Create rent-free associated token account + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/create-ata +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) + +SPL equivalent: spl_associated_token_account::create → Light Token: CreateAta + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|CreateAta|create_associated_token_account` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for ATA creation +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have ATA operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-cookbook/create-mint.mdx b/snippets/ai-prompts/rust-cookbook/create-mint.mdx new file mode 100644 index 00000000..14a310bb --- /dev/null +++ b/snippets/ai-prompts/rust-cookbook/create-mint.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Create rent-free mint with token metadata +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Create rent-free mint with token metadata + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/create-mint +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) + +SPL equivalent: spl_token::instruction::initialize_mint → Light Token: CreateMint + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|CreateMint|initialize_mint` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for mint creation +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have mint operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-cookbook/create-token-account.mdx b/snippets/ai-prompts/rust-cookbook/create-token-account.mdx new file mode 100644 index 00000000..925a4090 --- /dev/null +++ b/snippets/ai-prompts/rust-cookbook/create-token-account.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Create Light Token account +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Create Light Token account + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/create-token-account +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) + +SPL equivalent: spl_token::instruction::initialize_account → Light Token: CreateTokenAccount + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|CreateTokenAccount|initialize_account` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for token account creation +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have token account operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-cookbook/freeze-thaw.mdx b/snippets/ai-prompts/rust-cookbook/freeze-thaw.mdx new file mode 100644 index 00000000..53f9ecf6 --- /dev/null +++ b/snippets/ai-prompts/rust-cookbook/freeze-thaw.mdx @@ -0,0 +1,60 @@ +```text +--- +description: Freeze and thaw Light Token accounts +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Freeze and thaw Light Token accounts + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/freeze-thaw +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) + +- Freeze: prevents all transfers or token burns from a specific Light Token account +- Thaw: re-enables transfers on a frozen Light Token account +- Only the freeze authority (set at mint creation) can freeze or thaw accounts + +SPL equivalent: spl_token::instruction::freeze_account / thaw_account → Light Token: Freeze / Thaw + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|Freeze|Thaw|freeze_account|thaw_account` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for freeze/thaw +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have freeze/thaw operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-cookbook/mint-to.mdx b/snippets/ai-prompts/rust-cookbook/mint-to.mdx new file mode 100644 index 00000000..8efd91d5 --- /dev/null +++ b/snippets/ai-prompts/rust-cookbook/mint-to.mdx @@ -0,0 +1,56 @@ +```text +--- +description: Mint tokens to Light Token account +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Mint tokens to Light Token account + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/mint-to +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) + +SPL equivalent: spl_token::instruction::mint_to → Light Token: MintTo + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|MintTo|mint_to` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for minting +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have mint operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-cookbook/transfer-checked.mdx b/snippets/ai-prompts/rust-cookbook/transfer-checked.mdx new file mode 100644 index 00000000..bb1a9397 --- /dev/null +++ b/snippets/ai-prompts/rust-cookbook/transfer-checked.mdx @@ -0,0 +1,58 @@ +```text +--- +description: Transfer tokens with decimal validation +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Transfer tokens with decimal validation + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/transfer-checked +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) + +TransferChecked validates that the decimals parameter matches the mint's decimals. Use for Light→Light transfers when you need decimal verification. For transfers involving SPL or Token 2022 accounts, use TransferInterface instead. + +SPL equivalent: spl_token::instruction::transfer_checked → Light Token: TransferChecked + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|TransferChecked|transfer_checked` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for transfer checked +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have transfer operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-cookbook/transfer-interface.mdx b/snippets/ai-prompts/rust-cookbook/transfer-interface.mdx new file mode 100644 index 00000000..37fee293 --- /dev/null +++ b/snippets/ai-prompts/rust-cookbook/transfer-interface.mdx @@ -0,0 +1,61 @@ +```text +--- +description: Transfer tokens between Light Token and SPL accounts +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Transfer tokens between Light Token and SPL accounts + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/transfer-interface +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) + +TransferInterface transfers tokens between token accounts (SPL, Token 2022, or Light Token) in a single call. +- Light Token → Light Token: transfers between Light Token accounts +- SPL → Light Token: locks SPL tokens in interface PDA, mints to Light Token account +- Light Token → SPL: burns Light Token balance, releases SPL tokens from interface PDA + +SPL equivalent: spl_token::instruction::transfer → Light Token: TransferInterface + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|TransferInterface|transfer` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for transfers +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have transfer operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-cookbook/wrap-unwrap.mdx b/snippets/ai-prompts/rust-cookbook/wrap-unwrap.mdx new file mode 100644 index 00000000..ed5bb3e0 --- /dev/null +++ b/snippets/ai-prompts/rust-cookbook/wrap-unwrap.mdx @@ -0,0 +1,59 @@ +```text +--- +description: Wrap and unwrap SPL tokens to Light Token +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Wrap and unwrap SPL tokens to Light Token + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/wrap-unwrap +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) + +- Wrap: move tokens from SPL or Token 2022 account → Light Token ATA (hot balance) +- Unwrap: move tokens from Light Token ATA (hot balance) → SPL or Token 2022 account + +No direct SPL equivalent — Wrap/Unwrap are Light Token operations → Light Token: Wrap / Unwrap + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|Wrap|Unwrap|wrap|unwrap` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for wrap/unwrap +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have wrap/unwrap operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/rust-template.mdx b/snippets/ai-prompts/rust-template.mdx new file mode 100644 index 00000000..ed5021d5 --- /dev/null +++ b/snippets/ai-prompts/rust-template.mdx @@ -0,0 +1,57 @@ +```text +--- +description: {{OPERATION_DESCRIPTION}} +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## {{OPERATION_DESCRIPTION}} + +Context: +- Guide: https://zkcompression.com/light-token/cookbook/{{PAGE_SLUG}} +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: light-token-client (actions), light-token (instructions), light-client (RPC) +{{EXTRA_REFS}} + +SPL equivalent: {{SPL_FUNCTION}} → Light Token: {{LIGHT_FUNCTION}} + +### 1. Index project +- Grep `light_token::|light_token_client::|solana_sdk|Keypair|async{{EXTRA_GREP}}` across src/ +- Glob `**/*.rs` for project structure +- Identify: RPC setup, existing token ops, entry point for {{OP_SHORT}} +- Check Cargo.toml for existing light-* dependencies and solana-sdk version +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Rust Client tab +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing) +- AskUserQuestion: does the project already have token operations to extend, or is this greenfield? +- AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2` +- Follow the cookbook guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/streaming/mints.mdx b/snippets/ai-prompts/streaming/mints.mdx new file mode 100644 index 00000000..1187ea02 --- /dev/null +++ b/snippets/ai-prompts/streaming/mints.mdx @@ -0,0 +1,57 @@ +```text +--- +description: Stream light-mint accounts and metadata via Laserstream gRPC +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Stream light-mint accounts and metadata via Laserstream gRPC + +Context: +- Guide: https://zkcompression.com/light-token/toolkits/for-streaming-mints +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: helius-laserstream, light-token-interface, borsh, futures +- Token accounts streaming: https://zkcompression.com/light-token/toolkits/for-streaming-tokens + +Key APIs: LaserstreamConfig, subscribe(), Mint::deserialize(), ExtensionStruct::TokenMetadata + +### 1. Index project +- Grep `helius_laserstream|laserstream|subscribe|StreamExt|light_token_interface|Mint|cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: existing gRPC streaming setup, account caching, deserialization logic +- Read Cargo.toml — note existing dependencies +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Steps (Connect, Subscribe, Deserialize, Detect cold, Extract metadata) +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new streaming pipeline for mints, add mint streaming to existing token streaming, specific use case like metadata indexing) +- AskUserQuestion: mainnet or devnet? +- AskUserQuestion: do you need cold/hot transition detection, or just live mint state? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan +- Follow the guide's step order: Connect → Subscribe (account + transaction subs) → Deserialize Mint → Detect Cold → Extract Metadata +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add helius-laserstream@0.1 light-token-interface@0.3 borsh@0.10 futures@0.3 bs58@0.5 tokio --features full` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/streaming/tokens.mdx b/snippets/ai-prompts/streaming/tokens.mdx new file mode 100644 index 00000000..e414b019 --- /dev/null +++ b/snippets/ai-prompts/streaming/tokens.mdx @@ -0,0 +1,60 @@ +```text +--- +description: Stream light-token accounts via Laserstream gRPC +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Stream light-token accounts via Laserstream gRPC + +Context: +- Guide: https://zkcompression.com/light-token/toolkits/for-streaming-tokens +- Skills and resources index: https://zkcompression.com/skill.md +- Crates: helius-laserstream, light-token-interface, spl-pod, spl-token-2022-interface, borsh, futures +- Mint accounts streaming: https://zkcompression.com/light-token/toolkits/for-streaming-mints +- Point queries: light-client (LightClient, get_account_interface) + +Key APIs: LaserstreamConfig, subscribe(), PodAccount (pod_from_bytes), LightClient::get_account_interface() + +### 1. Index project +- Grep `helius_laserstream|laserstream|subscribe|PodAccount|pod_from_bytes|spl_token_2022_interface|cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m` across src/ +- Glob `**/*.rs` and `**/Cargo.toml` for project structure +- Identify: existing gRPC streaming setup, token account caching, SPL parser usage +- Read Cargo.toml — note existing dependencies +- Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel + +### 2. Read references +- WebFetch the guide above — follow the Steps (Connect, Subscribe) and the transition detection sections +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new streaming pipeline for token accounts, add to existing pipeline, integrate cold/hot detection for routing) +- AskUserQuestion: mainnet or devnet? +- AskUserQuestion: do you need point queries (get_account_interface) in addition to streaming? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan +- Follow the guide's structure: Connect → Subscribe (account + transaction subs) → Detect Transitions (hot-to-cold, cold-to-hot) → Point Queries (optional) +- Token accounts use the same 165-byte SPL layout — existing SPL parsers work directly +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `cargo add helius-laserstream@0.1 light-token-interface@0.3 spl-pod spl-token-2022-interface borsh@0.10 futures@0.3 bs58@0.5 tokio --features full` +- For point queries, also: Bash `cargo add light-client@0.19 --features v2` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `cargo check` +- Bash `cargo test` if tests exist +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/toolkits/airdrop.mdx b/snippets/ai-prompts/toolkits/airdrop.mdx new file mode 100644 index 00000000..d5b26220 --- /dev/null +++ b/snippets/ai-prompts/toolkits/airdrop.mdx @@ -0,0 +1,62 @@ +```text +--- +description: Distribute compressed tokens via airdrop +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Distribute compressed tokens via airdrop + +Context: +- Guide: https://zkcompression.com/compressed-tokens/airdrop +- Skills and resources index: https://zkcompression.com/skill.md +- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js, @solana/spl-token +- Example repo: https://github.com/Lightprotocol/example-token-distribution +- Webapp alternative: https://airship.helius.dev/ (Airship by Helius Labs, up to 200k recipients) + +Key APIs: LightTokenProgram.compress(), getTokenPoolInfos(), selectTokenPoolInfo(), getStateTreeInfos(), selectStateTreeInfo(), buildAndSignTx(), sendAndConfirmTx() + +### 1. Index project +- Grep `LightTokenProgram|compress|getTokenPoolInfos|selectTokenPoolInfo|getStateTreeInfos|@lightprotocol|airdrop|distribution` across src/ +- Glob `**/*.ts` for project structure +- Identify: existing airdrop/distribution logic, token minting setup, recipient list format +- Check package.json for existing @lightprotocol/* or @solana/spl-token dependencies +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — review all three tabs (Localnet Guide, Simple Airdrop, Batched) +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what scale? (<10k recipients = simple airdrop, 10k+ = batched) +- AskUserQuestion: localnet testing first, or production deploy? +- AskUserQuestion: do you have an existing SPL mint, or need to create one? +- AskUserQuestion: do you need decompression/claim functionality, or just direct distribution? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan +- For simple airdrop: create mint → mint SPL tokens → LightTokenProgram.compress() with recipients array +- For batched: create instruction batches → manage blockhash refresh → sign and send with retry logic +- Address lookup table needed for production (mainnet: 9NYFyEqPkyXUhkerbGHXUXkvb4qpzeEdHuGpgbgpH1NJ) +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js @solana/spl-token` +- Set up RPC: `createRpc(RPC_ENDPOINT)` with a ZK Compression endpoint (Helius, Triton) +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `tsc --noEmit` +- Bash run existing test suite or execute localnet test airdrop +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/toolkits/nullifiers.mdx b/snippets/ai-prompts/toolkits/nullifiers.mdx new file mode 100644 index 00000000..8df8b9b6 --- /dev/null +++ b/snippets/ai-prompts/toolkits/nullifiers.mdx @@ -0,0 +1,63 @@ +```text +--- +description: Create rent-free nullifier PDAs to prevent duplicate actions +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Create rent-free nullifier PDAs to prevent duplicate actions + +Context: +- Guide: https://zkcompression.com/pda/compressed-pdas/guides/how-to-create-nullifier-pdas +- Skills and resources index: https://zkcompression.com/skill.md +- Rust crates: light-nullifier-program, light-client +- TS packages: @lightprotocol/nullifier-program, @lightprotocol/stateless.js +- Example: https://github.com/Lightprotocol/examples-light-token/blob/main/rust-client/actions/create_nullifier.rs +- Program source: https://github.com/Lightprotocol/nullifier-program/ + +Key APIs: +- Rust: create_nullifier_ix(), fetch_proof(), build_instruction(), derive_nullifier_address() +- TS: createNullifierIx(), fetchProof(), buildInstruction(), deriveNullifierAddress() + +### 1. Index project +- Grep `nullifier|create_nullifier|createNullifierIx|deriveNullifierAddress|NFLx5WGPrTHHvdRNsidcrNcLxRruMC92E4yv7zhZBoT` across src/ +- Glob `**/*.rs` and `**/*.ts` for project structure +- Identify: existing transaction building, duplicate prevention logic, payment flow +- Check Cargo.toml or package.json for existing light-* dependencies +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — review both Rust and TS code samples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: Rust or TypeScript? +- AskUserQuestion: what is the goal? (prevent duplicate payments, idempotent instruction execution, other use case) +- AskUserQuestion: do you need the helper (create_nullifier_ix) or manual proof fetching (fetch_proof + build_instruction)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Follow the guide's pattern: create unique 32-byte ID → build nullifier instruction → prepend to transaction +- If checking existence is needed, add derive_nullifier_address + get_compressed_account check +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- For Rust: Bash `cargo add light-nullifier-program@0.1 light-client@0.19` +- For TypeScript: Bash `npm install @lightprotocol/nullifier-program @lightprotocol/stateless.js@beta` +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Rust: Bash `cargo check` + `cargo test` if tests exist +- TypeScript: Bash `tsc --noEmit` + run existing test suite if present +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/toolkits/payments.mdx b/snippets/ai-prompts/toolkits/payments.mdx new file mode 100644 index 00000000..60ab5381 --- /dev/null +++ b/snippets/ai-prompts/toolkits/payments.mdx @@ -0,0 +1,67 @@ +```text +--- +description: Integrate light-token APIs for stablecoin payments +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Integrate light-token APIs for stablecoin payments + +Context: +- Guide: https://zkcompression.com/light-token/toolkits/for-payments +- Skills and resources index: https://zkcompression.com/skill.md +- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js +- Full examples: https://github.com/Lightprotocol/examples-light-token/tree/main/toolkits/payments-and-wallets + +SPL → Light Token API mapping: +| Operation | SPL | Light Token | +| Receive | getOrCreateAssociatedTokenAccount() | createLoadAtaInstructions() / loadAta() | +| Transfer | createTransferInstruction() | createTransferInterfaceInstructions() | +| Get Balance | getAccount() | getAtaInterface() | +| Tx History | getSignaturesForAddress() | getSignaturesForOwnerInterface() | +| Wrap SPL | N/A | createWrapInstruction() / wrap() | +| Unwrap | N/A | createUnwrapInstructions() / unwrap() | + +### 1. Index project +- Grep `@solana/spl-token|@lightprotocol|createTransferInstruction|getAccount|Connection|Keypair|stablecoin|payment` across src/ +- Glob `**/*.ts` and `**/*.tsx` for project structure +- Identify: RPC setup, existing token operations, payment flow, wallet signing pattern +- Check package.json for existing @lightprotocol/* or @solana/spl-token dependencies +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — review Instruction and Action tabs for each operation +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new payment integration, migrate existing SPL payment flow, add alongside existing SPL) +- AskUserQuestion: which operations? (receive, send, balance, history, wrap, unwrap — or all) +- AskUserQuestion: instruction-level API (build your own transactions) or action-level API (high-level, fewer lines)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing connection/signer setup is compatible (createRpc with ZK Compression endpoint) +- Key pattern: import from `@lightprotocol/compressed-token/unified` for all interface APIs +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js` +- Set up RPC: `createRpc(RPC_ENDPOINT)` with a ZK Compression endpoint (Helius, Triton) +- Import from `@lightprotocol/compressed-token/unified` for the interface APIs +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `tsc --noEmit` +- Bash run existing test suite if present +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/toolkits/wallets.mdx b/snippets/ai-prompts/toolkits/wallets.mdx new file mode 100644 index 00000000..ca1da60e --- /dev/null +++ b/snippets/ai-prompts/toolkits/wallets.mdx @@ -0,0 +1,68 @@ +```text +--- +description: Add light-token support to a wallet application +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Add light-token support to a wallet application + +Context: +- Guide: https://zkcompression.com/light-token/toolkits/for-wallets +- Skills and resources index: https://zkcompression.com/skill.md +- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js +- Full examples: https://github.com/Lightprotocol/examples-light-token/tree/main/toolkits/payments-and-wallets + +SPL → Light Token API mapping: +| Operation | SPL | Light Token | +| Receive | getOrCreateAssociatedTokenAccount() | createLoadAtaInstructions() / loadAta() | +| Transfer | createTransferInstruction() | createTransferInterfaceInstructions() | +| Get Balance | getAccount() | getAtaInterface() | +| Tx History | getSignaturesForAddress() | getSignaturesForOwnerInterface() | +| Wrap SPL | N/A | createWrapInstruction() / wrap() | +| Unwrap | N/A | createUnwrapInstructions() / unwrap() | + +### 1. Index project +- Grep `@solana/spl-token|@lightprotocol|createTransferInstruction|getAccount|wallet|signTransaction|signAllTransactions|Connection` across src/ +- Glob `**/*.ts` and `**/*.tsx` for project structure +- Identify: RPC setup, existing token display/balance logic, wallet adapter, transaction signing pattern +- Check package.json for existing @lightprotocol/* or @solana/spl-token dependencies +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — review Instruction and Action tabs for each operation +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: what is the goal? (new wallet integration, migrate existing SPL wallet to light-token, add light-token alongside existing SPL) +- AskUserQuestion: which operations? (receive, send, balance, history, wrap, unwrap — or all) +- AskUserQuestion: instruction-level API (build your own transactions) or action-level API (high-level, fewer lines)? +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing connection/signer setup is compatible (createRpc with ZK Compression endpoint) +- Key pattern: import from `@lightprotocol/compressed-token/unified` for all interface APIs +- APIs return TransactionInstruction[][] — handle multi-tx case with signAllTransactions +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js` +- Set up RPC: `createRpc(RPC_ENDPOINT)` with a ZK Compression endpoint (Helius, Triton) +- Import from `@lightprotocol/compressed-token/unified` for the interface APIs +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `tsc --noEmit` +- Bash run existing test suite if present +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/ai-prompts/wallets/privy.mdx b/snippets/ai-prompts/wallets/privy.mdx new file mode 100644 index 00000000..1b53baa0 --- /dev/null +++ b/snippets/ai-prompts/wallets/privy.mdx @@ -0,0 +1,67 @@ +```text +--- +description: Integrate light-token with Privy embedded wallets +allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression +--- + +## Integrate light-token with Privy embedded wallets + +Context: +- Guide: https://zkcompression.com/light-token/toolkits/for-privy +- Skills and resources index: https://zkcompression.com/skill.md +- Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js +- Node.js example: https://github.com/Lightprotocol/examples-light-token/tree/main/privy/nodejs +- React example: https://github.com/Lightprotocol/examples-light-token/tree/main/privy/react + +SPL → Light Token API mapping: +| Operation | SPL | Light Token | +| Transfer | createTransferInstruction() | createTransferInterfaceInstructions() | +| Wrap SPL→Light | N/A | createWrapInstruction() | +| Unwrap Light→SPL | N/A | createUnwrapInstructions() | +| Get balance | getAccount() | getAtaInterface() | +| Tx history | getSignaturesForAddress() | getSignaturesForOwnerInterface() | + +### 1. Index project +- Grep `privy|@privy-io|usePrivy|PrivyProvider|createTransferInstruction|@solana/spl-token|Connection` across src/ +- Glob `**/*.ts` and `**/*.tsx` for project structure +- Identify: Privy SDK version, existing wallet setup, RPC config, token operations +- Check package.json for existing @lightprotocol/* or @solana/spl-token dependencies +- Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel + +### 2. Read references +- WebFetch the guide above — review both Node.js and React code examples +- WebFetch skill.md — check for a dedicated skill and resources matching this task +- TaskCreate one todo per phase below to track progress + +### 3. Clarify intention +- AskUserQuestion: Node.js or React? +- AskUserQuestion: what is the goal? (new Privy integration, migrate existing Privy+SPL code, add light-token alongside existing SPL) +- AskUserQuestion: which operations? (transfer, wrap, unwrap, balances, tx history — or all) +- Summarize findings and wait for user confirmation before implementing + +### 4. Create plan +- Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes +- Verify existing Privy wallet setup is compatible (signTransaction or sendTransaction pattern) +- Key integration pattern: build unsigned tx with light-token SDK → sign with Privy → send to RPC +- If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion) +- Present the plan to the user for approval before proceeding + +### 5. Implement +- Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js` +- Set up RPC: `createRpc(RPC_ENDPOINT)` with a ZK Compression endpoint (Helius, Triton) +- Import from `@lightprotocol/compressed-token/unified` for the interface APIs +- Follow the guide and the approved plan +- Write/Edit to create or modify files +- TaskUpdate to mark each step done + +### 6. Verify +- Bash `tsc --noEmit` +- Bash run existing test suite if present +- TaskUpdate to mark complete + +### Tools +- mcp__zkcompression__SearchLightProtocol("") for API details +- mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "") for architecture +- Task subagent with Grep/Read/WebFetch for parallel lookups +- TaskList to check remaining work +``` diff --git a/snippets/code-snippets/privy/balances/nodejs.mdx b/snippets/code-snippets/privy/balances/nodejs.mdx index 0fcafdb2..e3aedf16 100644 --- a/snippets/code-snippets/privy/balances/nodejs.mdx +++ b/snippets/code-snippets/privy/balances/nodejs.mdx @@ -7,22 +7,24 @@ import { getAtaInterface, getAssociatedTokenAddressInterface, } from '@lightprotocol/compressed-token/unified'; + +interface TokenBalance { + mint: string; + decimals: number; + hot: number; + cold: number; + spl: number; + t22: number; + unified: number; +} + interface BalanceBreakdown { sol: number; - token?: { - mint: string; - unified: number; - decimals: number; - hot: number; - cold: number; - spl: number; - t22: number; - }; + tokens: TokenBalance[]; } export async function getBalances( ownerAddress: string, - mintAddress?: string, ): Promise { const rpc = createRpc(process.env.HELIUS_RPC_URL!); const owner = new PublicKey(ownerAddress); @@ -35,44 +37,22 @@ export async function getBalances( console.error('Failed to fetch SOL balance:', e); } - const result: BalanceBreakdown = { - sol: solLamports / LAMPORTS_PER_SOL, - }; - - if (!mintAddress) { - return result; - } - - const mint = new PublicKey(mintAddress); - const ata = getAssociatedTokenAddressInterface(mint, owner); + // Per-mint accumulator + const mintMap = new Map(); - const decimals = 9; - let hot = 0; - let cold = 0; - let spl = 0; - let t22 = 0; - - // 1. Hot balance (light-token associated token account on-chain) - try { - const {parsed} = await getAtaInterface(rpc, ata, owner, mint); - hot = toUiAmount(parsed.amount, decimals); - } catch { - // Associated token account may not exist yet - } - - // 2. Cold balance (compressed token accounts) - try { - const compressed = await rpc.getCompressedTokenBalancesByOwnerV2(owner, { - mint, - }); - for (const item of compressed.value.items) { - cold += toUiAmount(item.balance, decimals); + const getOrCreate = (mintStr: string) => { + let entry = mintMap.get(mintStr); + if (!entry) { + entry = {spl: 0, t22: 0, hot: 0, cold: 0, decimals: 9}; + mintMap.set(mintStr, entry); } - } catch { - // No compressed accounts - } + return entry; + }; - // 3. SPL balance (standard token program accounts) + // Track Light Token associated token accounts so we don't double-count them as Token 2022 balances + const lightAtaMints = new Set(); + + // 1. SPL accounts (standard token program) try { const splAccounts = await rpc.getTokenAccountsByOwner(owner, { programId: TOKEN_PROGRAM_ID, @@ -80,43 +60,80 @@ export async function getBalances( for (const {account} of splAccounts.value) { const buf = toBuffer(account.data); if (!buf || buf.length < 72) continue; - const accountMint = new PublicKey(buf.subarray(0, 32)); - if (!accountMint.equals(mint)) continue; - spl += toUiAmount(buf.readBigUInt64LE(64), decimals); + const mint = new PublicKey(buf.subarray(0, 32)); + const amount = buf.readBigUInt64LE(64); + const mintStr = mint.toBase58(); + getOrCreate(mintStr).spl += toUiAmount(amount, 9); } } catch { // No SPL accounts } - // 4. T22 balance (Token-2022 accounts) + // 2. T22 accounts (Token-2022) — skip Light Token associated token accounts try { const t22Accounts = await rpc.getTokenAccountsByOwner(owner, { programId: TOKEN_2022_PROGRAM_ID, }); - for (const {account} of t22Accounts.value) { + for (const {pubkey, account} of t22Accounts.value) { const buf = toBuffer(account.data); if (!buf || buf.length < 72) continue; - const accountMint = new PublicKey(buf.subarray(0, 32)); - if (!accountMint.equals(mint)) continue; - t22 += toUiAmount(buf.readBigUInt64LE(64), decimals); + const mint = new PublicKey(buf.subarray(0, 32)); + const mintStr = mint.toBase58(); + const expectedAta = getAssociatedTokenAddressInterface(mint, owner); + if (pubkey.equals(expectedAta)) { + // Light Token associated token account — query via getAtaInterface instead + lightAtaMints.add(mintStr); + getOrCreate(mintStr); + } else { + const amount = buf.readBigUInt64LE(64); + getOrCreate(mintStr).t22 += toUiAmount(amount, 9); + } } } catch { - // No T22 accounts + // No Token 2022 accounts } - const unified = hot + cold; + // 3. Hot balance via getAtaInterface (parallelize per mint) + const mintKeys = [...mintMap.keys()]; + await Promise.allSettled( + mintKeys.map(async (mintStr) => { + try { + const mint = new PublicKey(mintStr); + const ata = getAssociatedTokenAddressInterface(mint, owner); + const {parsed} = await getAtaInterface(rpc, ata, owner, mint); + getOrCreate(mintStr).hot = toUiAmount(parsed.amount, 9); + } catch { + // Associated token account does not exist for this mint + } + }), + ); + + // 4. Cold balance (compressed token accounts — all mints at once) + try { + const compressed = await rpc.getCompressedTokenBalancesByOwnerV2(owner); + for (const item of compressed.value.items) { + const mintStr = item.mint.toBase58(); + getOrCreate(mintStr).cold += toUiAmount(BigInt(item.balance.toString()), 9); + } + } catch { + // No compressed accounts + } - result.token = { - mint: mintAddress, - unified, - decimals, - hot, - cold, - spl, - t22, - }; + // Assemble result + const tokens: TokenBalance[] = []; + for (const [mintStr, entry] of mintMap) { + tokens.push({ + mint: mintStr, + decimals: entry.decimals, + hot: entry.hot, + cold: entry.cold, + spl: entry.spl, + t22: entry.t22, + unified: entry.hot + entry.cold, + }); + } - return result; + return {sol: solLamports / LAMPORTS_PER_SOL, tokens}; } function toBuffer(data: Buffer | Uint8Array | string | unknown): Buffer | null { @@ -131,4 +148,5 @@ function toUiAmount(raw: bigint | {toNumber: () => number}, decimals: number): n } export default getBalances; + ``` diff --git a/snippets/code-snippets/privy/balances/react.mdx b/snippets/code-snippets/privy/balances/react.mdx index d76d7a57..b32bf6a7 100644 --- a/snippets/code-snippets/privy/balances/react.mdx +++ b/snippets/code-snippets/privy/balances/react.mdx @@ -1 +1,171 @@ -React example coming soon. +```typescript +import { useState, useCallback } from 'react'; +import { PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js'; +import { TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID } from '@solana/spl-token'; +import { createRpc } from '@lightprotocol/stateless.js'; +import { + getAssociatedTokenAddressInterface, + getAtaInterface, +} from '@lightprotocol/compressed-token/unified'; + +export interface TokenBalance { + mint: string; + decimals: number; + isNative: boolean; + hot: bigint; + cold: bigint; + spl: bigint; + t22: bigint; + unified: bigint; +} + +export function useLightTokenBalances() { + const [balances, setBalances] = useState([]); + const [isLoading, setIsLoading] = useState(false); + + const fetchBalances = useCallback(async (ownerAddress: string) => { + if (!ownerAddress) return; + + setIsLoading(true); + try { + const rpc = createRpc(import.meta.env.VITE_HELIUS_RPC_URL); + const owner = new PublicKey(ownerAddress); + + // Per-mint accumulator + const mintMap = new Map(); + + const getOrCreate = (mintStr: string) => { + let entry = mintMap.get(mintStr); + if (!entry) { + entry = { spl: 0n, t22: 0n, hot: 0n, cold: 0n, decimals: 9 }; + mintMap.set(mintStr, entry); + } + return entry; + }; + + // Track which mints we found via T22 light-token ATAs (skip in t22 accumulation) + const lightAtaMints = new Set(); + + // 1. SOL balance + let solLamports = 0; + try { + solLamports = await rpc.getBalance(owner); + } catch { + // Failed to fetch SOL balance + } + + // 2. SPL accounts (standard token program) + try { + const splAccounts = await rpc.getTokenAccountsByOwner(owner, { + programId: TOKEN_PROGRAM_ID, + }); + for (const { account } of splAccounts.value) { + const buf = toBuffer(account.data); + if (!buf || buf.length < 72) continue; + const mint = new PublicKey(buf.subarray(0, 32)); + const amount = buf.readBigUInt64LE(64); + const mintStr = mint.toBase58(); + getOrCreate(mintStr).spl += amount; + } + } catch { + // No SPL accounts + } + + // 3. T22 accounts (Token-2022) + try { + const t22Accounts = await rpc.getTokenAccountsByOwner(owner, { + programId: TOKEN_2022_PROGRAM_ID, + }); + for (const { pubkey, account } of t22Accounts.value) { + const buf = toBuffer(account.data); + if (!buf || buf.length < 72) continue; + const mint = new PublicKey(buf.subarray(0, 32)); + const mintStr = mint.toBase58(); + const expectedAta = getAssociatedTokenAddressInterface(mint, owner); + if (pubkey.equals(expectedAta)) { + // This is a light-token ATA — will query via getAtaInterface instead + lightAtaMints.add(mintStr); + getOrCreate(mintStr); // ensure entry exists for hot balance query + } else { + const amount = buf.readBigUInt64LE(64); + getOrCreate(mintStr).t22 += amount; + } + } + } catch { + // No T22 accounts + } + + // 4. Hot balance via getAtaInterface (parallelize per mint) + const mintKeys = [...mintMap.keys()]; + await Promise.allSettled( + mintKeys.map(async (mintStr) => { + try { + const mint = new PublicKey(mintStr); + const ata = getAssociatedTokenAddressInterface(mint, owner); + const { parsed } = await getAtaInterface(rpc, ata, owner, mint); + const entry = getOrCreate(mintStr); + entry.hot = BigInt(parsed.amount.toString()); + } catch { + // ATA does not exist for this mint — hot stays 0n + } + }), + ); + + // 5. Cold balance (compressed token accounts) + try { + const compressed = await rpc.getCompressedTokenBalancesByOwnerV2(owner); + for (const item of compressed.value.items) { + const mintStr = item.mint.toBase58(); + getOrCreate(mintStr).cold += BigInt(item.balance.toString()); + } + } catch { + // No compressed accounts + } + + // 6. Assemble TokenBalance[] + const result: TokenBalance[] = []; + + // SOL entry + result.push({ + mint: 'So11111111111111111111111111111111111111112', + decimals: 9, + isNative: true, + hot: 0n, + cold: 0n, + spl: BigInt(solLamports), + t22: 0n, + unified: 0n, + }); + + // Token entries + for (const [mintStr, entry] of mintMap) { + result.push({ + mint: mintStr, + decimals: entry.decimals, + isNative: false, + hot: entry.hot, + cold: entry.cold, + spl: entry.spl, + t22: entry.t22, + unified: entry.hot + entry.cold, + }); + } + + setBalances(result); + } catch (error) { + console.error('Failed to fetch balances:', error); + setBalances([]); + } finally { + setIsLoading(false); + } + }, []); + + return { balances, isLoading, fetchBalances }; +} + +function toBuffer(data: Buffer | Uint8Array | string | unknown): Buffer | null { + if (data instanceof Buffer) return data; + if (data instanceof Uint8Array) return Buffer.from(data); + return null; +} +``` diff --git a/snippets/code-snippets/privy/helpers/sign-and-send-batches.mdx b/snippets/code-snippets/privy/helpers/sign-and-send-batches.mdx new file mode 100644 index 00000000..082607d7 --- /dev/null +++ b/snippets/code-snippets/privy/helpers/sign-and-send-batches.mdx @@ -0,0 +1,46 @@ +```typescript +import { Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js'; +import type { ConnectedStandardSolanaWallet } from '@privy-io/js-sdk-core'; +import { useSignTransaction } from '@privy-io/react-auth/solana'; + +type SignTransactionFn = ReturnType['signTransaction']; + +interface SignAndSendOptions { + rpc: any; + feePayer: PublicKey; + wallet: ConnectedStandardSolanaWallet; + signTransaction: SignTransactionFn; +} + +export async function signAndSendBatches( + instructionBatches: TransactionInstruction[][], + options: SignAndSendOptions, +): Promise { + const { rpc, feePayer, wallet, signTransaction } = options; + const signatures: string[] = []; + + for (const ixs of instructionBatches) { + const tx = new Transaction().add(...ixs); + const { blockhash } = await rpc.getLatestBlockhash(); + tx.recentBlockhash = blockhash; + tx.feePayer = feePayer; + + const unsignedTxBuffer = tx.serialize({ requireAllSignatures: false }); + const signedTx = await signTransaction({ + transaction: unsignedTxBuffer, + wallet, + chain: 'solana:devnet', + }); + + const signedTxBuffer = Buffer.from(signedTx.signedTransaction); + const sig = await rpc.sendRawTransaction(signedTxBuffer, { + skipPreflight: false, + preflightCommitment: 'confirmed', + }); + await rpc.confirmTransaction(sig, 'confirmed'); + signatures.push(sig); + } + + return signatures.length > 0 ? signatures[signatures.length - 1] : null; +} +``` diff --git a/snippets/code-snippets/privy/transaction-history/nodejs.mdx b/snippets/code-snippets/privy/transaction-history/nodejs.mdx index 994de4bc..00fce8c1 100644 --- a/snippets/code-snippets/privy/transaction-history/nodejs.mdx +++ b/snippets/code-snippets/privy/transaction-history/nodejs.mdx @@ -11,7 +11,7 @@ const getTransactionHistory = async ( const owner = new PublicKey(ownerAddress); - // Get light-token interface signatures + // Get Light Token interface signatures const result = await connection.getSignaturesForOwnerInterface(owner); if (!result.signatures || result.signatures.length === 0) { @@ -37,4 +37,5 @@ const getTransactionHistory = async ( }; export default getTransactionHistory; + ``` diff --git a/snippets/code-snippets/privy/transaction-history/react.mdx b/snippets/code-snippets/privy/transaction-history/react.mdx index d76d7a57..1c98218e 100644 --- a/snippets/code-snippets/privy/transaction-history/react.mdx +++ b/snippets/code-snippets/privy/transaction-history/react.mdx @@ -1 +1,65 @@ -React example coming soon. +```typescript +import { useState, useCallback } from 'react'; +import { PublicKey } from '@solana/web3.js'; +import { createRpc } from '@lightprotocol/stateless.js'; + +export interface Transaction { + signature: string; + slot: number; + blockTime: number; + timestamp: string; +} + +export function useTransactionHistory() { + const [transactions, setTransactions] = useState([]); + const [isLoading, setIsLoading] = useState(false); + const [error, setError] = useState(null); + + const fetchTransactionHistory = useCallback( + async ( + ownerAddress: string, + limit: number = 10, + ) => { + if (!ownerAddress) { + setTransactions([]); + return; + } + + setIsLoading(true); + setError(null); + + try { + const rpc = createRpc(import.meta.env.VITE_HELIUS_RPC_URL); + const owner = new PublicKey(ownerAddress); + + const result = await rpc.getSignaturesForOwnerInterface(owner); + + if (!result.signatures || result.signatures.length === 0) { + setTransactions([]); + return; + } + + const limitedSignatures = result.signatures.slice(0, limit); + + const basicTransactions = limitedSignatures.map((sig) => ({ + signature: sig.signature, + slot: sig.slot, + blockTime: sig.blockTime ?? 0, + timestamp: sig.blockTime ? new Date(sig.blockTime * 1000).toISOString() : '', + })); + + setTransactions(basicTransactions); + } catch (err) { + const message = err instanceof Error ? err.message : String(err); + setError(message); + setTransactions([]); + } finally { + setIsLoading(false); + } + }, + [] + ); + + return { transactions, isLoading, error, fetchTransactionHistory }; +} +``` diff --git a/snippets/code-snippets/privy/transfer/nodejs.mdx b/snippets/code-snippets/privy/transfer/nodejs.mdx index 76cb051d..4a0844e4 100644 --- a/snippets/code-snippets/privy/transfer/nodejs.mdx +++ b/snippets/code-snippets/privy/transfer/nodejs.mdx @@ -26,9 +26,8 @@ const transferLightTokens = async ( const mintPubkey = new PublicKey(tokenMintAddress); const tokenAmount = Math.floor(amount * Math.pow(10, decimals)); - // Returns TransactionInstruction[][]. - // Each inner array is one transaction. - // Almost always returns just one. + // Loads cold (compressed), SPL, and Token 2022 balances into the Light Token associated token account before transfer. + // Returns TransactionInstruction[][] — send [0..n-2] in parallel, then [n-1] last. const instructions = await createTransferInterfaceInstructions( connection, fromPubkey, mintPubkey, tokenAmount, fromPubkey, toPubkey, ); @@ -63,4 +62,5 @@ const transferLightTokens = async ( }; export default transferLightTokens; + ``` diff --git a/snippets/code-snippets/privy/transfer/react.mdx b/snippets/code-snippets/privy/transfer/react.mdx index d76d7a57..e5a3e715 100644 --- a/snippets/code-snippets/privy/transfer/react.mdx +++ b/snippets/code-snippets/privy/transfer/react.mdx @@ -1 +1,71 @@ -React example coming soon. +```typescript +import { useState } from 'react'; +import { PublicKey } from '@solana/web3.js'; +import { + createTransferInterfaceInstructions, +} from '@lightprotocol/compressed-token/unified'; +import { createRpc } from '@lightprotocol/stateless.js'; +import type { ConnectedStandardSolanaWallet } from '@privy-io/js-sdk-core'; +import { useSignTransaction } from '@privy-io/react-auth/solana'; +import { signAndSendBatches } from './signAndSendBatches'; + +type SignTransactionFn = ReturnType['signTransaction']; + +export interface TransferParams { + ownerPublicKey: string; + mint: string; + toAddress: string; + amount: number; + decimals?: number; +} + +export interface TransferArgs { + params: TransferParams; + wallet: ConnectedStandardSolanaWallet; + signTransaction: SignTransactionFn; +} + +export function useTransfer() { + const [isLoading, setIsLoading] = useState(false); + + const transfer = async (args: TransferArgs): Promise => { + setIsLoading(true); + + try { + const { params, wallet, signTransaction } = args; + const { ownerPublicKey, mint, toAddress, amount, decimals = 9 } = params; + + const rpc = createRpc(import.meta.env.VITE_HELIUS_RPC_URL); + + const owner = new PublicKey(ownerPublicKey); + const mintPubkey = new PublicKey(mint); + const recipient = new PublicKey(toAddress); + const tokenAmount = Math.floor(amount * Math.pow(10, decimals)); + + // Returns TransactionInstruction[][]. + // Each inner array is one transaction. + // Almost always returns just one. + const instructions = await createTransferInterfaceInstructions( + rpc, owner, mintPubkey, tokenAmount, owner, recipient, + ); + + const signature = await signAndSendBatches(instructions, { + rpc, + feePayer: owner, + wallet, + signTransaction, + }); + + if (!signature) { + throw new Error('Transfer returned no instructions'); + } + + return signature; + } finally { + setIsLoading(false); + } + }; + + return { transfer, isLoading }; +} +``` diff --git a/snippets/code-snippets/privy/unwrap/nodejs.mdx b/snippets/code-snippets/privy/unwrap/nodejs.mdx index dfaba54d..1bc631e2 100644 --- a/snippets/code-snippets/privy/unwrap/nodejs.mdx +++ b/snippets/code-snippets/privy/unwrap/nodejs.mdx @@ -25,8 +25,13 @@ const unwrapTokens = async ( const mintPubkey = new PublicKey(tokenMintAddress); const tokenAmount = BigInt(Math.floor(amount * Math.pow(10, decimals))); + // Auto-detect token program (SPL vs Token 2022) from mint account owner + const mintAccountInfo = await connection.getAccountInfo(mintPubkey); + if (!mintAccountInfo) throw new Error(`Mint account ${tokenMintAddress} not found`); + const tokenProgramId = mintAccountInfo.owner; + // Destination: SPL/T22 associated token account - const splAta = getAssociatedTokenAddressSync(mintPubkey, fromPubkey); + const splAta = getAssociatedTokenAddressSync(mintPubkey, fromPubkey, false, tokenProgramId); // Returns TransactionInstruction[][]. // Each inner array is one transaction. @@ -65,4 +70,5 @@ const unwrapTokens = async ( }; export default unwrapTokens; + ``` diff --git a/snippets/code-snippets/privy/unwrap/react.mdx b/snippets/code-snippets/privy/unwrap/react.mdx index d76d7a57..cf5def70 100644 --- a/snippets/code-snippets/privy/unwrap/react.mdx +++ b/snippets/code-snippets/privy/unwrap/react.mdx @@ -1 +1,78 @@ -React example coming soon. +```typescript +import { useState } from 'react'; +import { PublicKey } from '@solana/web3.js'; +import { getAssociatedTokenAddressSync } from '@solana/spl-token'; +import { + createUnwrapInstructions, +} from '@lightprotocol/compressed-token/unified'; +import { createRpc } from '@lightprotocol/stateless.js'; +import type { ConnectedStandardSolanaWallet } from '@privy-io/js-sdk-core'; +import { useSignTransaction } from '@privy-io/react-auth/solana'; +import { signAndSendBatches } from './signAndSendBatches'; + +type SignTransactionFn = ReturnType['signTransaction']; + +export interface UnwrapParams { + ownerPublicKey: string; + mint: string; + amount: number; + decimals?: number; +} + +export interface UnwrapArgs { + params: UnwrapParams; + wallet: ConnectedStandardSolanaWallet; + signTransaction: SignTransactionFn; +} + +export function useUnwrap() { + const [isLoading, setIsLoading] = useState(false); + + const unwrap = async (args: UnwrapArgs): Promise => { + setIsLoading(true); + + try { + const { params, wallet, signTransaction } = args; + const { ownerPublicKey, mint, amount, decimals = 9 } = params; + + const rpc = createRpc(import.meta.env.VITE_HELIUS_RPC_URL); + + const owner = new PublicKey(ownerPublicKey); + const mintPubkey = new PublicKey(mint); + const tokenAmount = BigInt(Math.floor(amount * Math.pow(10, decimals))); + + // Auto-detect token program (SPL vs T22) from mint account owner + const mintAccountInfo = await rpc.getAccountInfo(mintPubkey); + if (!mintAccountInfo) throw new Error(`Mint account ${mint} not found`); + const tokenProgramId = mintAccountInfo.owner; + + // Destination: SPL/T22 associated token account + const splAta = getAssociatedTokenAddressSync(mintPubkey, owner, false, tokenProgramId); + + // Returns TransactionInstruction[][]. + // Each inner array is one transaction. + // Handles loading + unwrapping together. + const instructions = await createUnwrapInstructions( + rpc, splAta, owner, mintPubkey, tokenAmount, owner, + ); + + const signature = await signAndSendBatches(instructions, { + rpc, + feePayer: owner, + wallet, + signTransaction, + }); + + if (!signature) { + throw new Error('Unwrap returned no instructions'); + } + + return signature; + } finally { + setIsLoading(false); + } + }; + + return { unwrap, isLoading }; +} +``` diff --git a/snippets/code-snippets/privy/wrap/nodejs.mdx b/snippets/code-snippets/privy/wrap/nodejs.mdx index 61f1b1e2..bf34ca1c 100644 --- a/snippets/code-snippets/privy/wrap/nodejs.mdx +++ b/snippets/code-snippets/privy/wrap/nodejs.mdx @@ -28,14 +28,14 @@ const wrapTokens = async ( const mintPubkey = new PublicKey(tokenMintAddress); const tokenAmount = BigInt(Math.floor(amount * Math.pow(10, decimals))); - // Get SPL interface info — determines whether mint uses SPL or T22 + // Get SPL interface info — determines whether mint uses SPL or Token 2022 const splInterfaceInfos = await getSplInterfaceInfos(connection, mintPubkey); const splInterfaceInfo = splInterfaceInfos.find( (info) => info.isInitialized, ); if (!splInterfaceInfo) throw new Error('No SPL interface found for this mint'); - // Derive source associated token account using the mint's token program (SPL or T22) + // Derive source associated token account using the mint's token program (SPL or Token 2022) const {tokenProgram} = splInterfaceInfo; const splAta = getAssociatedTokenAddressSync(mintPubkey, fromPubkey, false, tokenProgram); const ataAccount = await getAccount(connection, splAta, undefined, tokenProgram); @@ -43,7 +43,7 @@ const wrapTokens = async ( throw new Error('Insufficient SPL balance'); } - // Derive light-token associated token account + // Derive Light Token associated token account const lightTokenAta = getAssociatedTokenAddressInterface(mintPubkey, fromPubkey); // Build instructions @@ -83,4 +83,5 @@ const wrapTokens = async ( }; export default wrapTokens; + ``` diff --git a/snippets/code-snippets/privy/wrap/react.mdx b/snippets/code-snippets/privy/wrap/react.mdx index d76d7a57..4cefafd5 100644 --- a/snippets/code-snippets/privy/wrap/react.mdx +++ b/snippets/code-snippets/privy/wrap/react.mdx @@ -1 +1,99 @@ -React example coming soon. +```typescript +import { useState } from 'react'; +import { PublicKey, Transaction, ComputeBudgetProgram } from '@solana/web3.js'; +import { getAssociatedTokenAddressSync, getAccount } from '@solana/spl-token'; +import { getSplInterfaceInfos } from '@lightprotocol/compressed-token'; +import { + createWrapInstruction, + getAssociatedTokenAddressInterface, + createAssociatedTokenAccountInterfaceIdempotentInstruction, +} from '@lightprotocol/compressed-token/unified'; +import { createRpc, CTOKEN_PROGRAM_ID } from '@lightprotocol/stateless.js'; +import type { ConnectedStandardSolanaWallet } from '@privy-io/js-sdk-core'; +import { useSignTransaction } from '@privy-io/react-auth/solana'; + +type SignTransactionFn = ReturnType['signTransaction']; + +export interface WrapParams { + ownerPublicKey: string; + mint: string; + amount: number; + decimals?: number; +} + +export interface WrapArgs { + params: WrapParams; + wallet: ConnectedStandardSolanaWallet; + signTransaction: SignTransactionFn; +} + +export function useWrap() { + const [isLoading, setIsLoading] = useState(false); + + const wrap = async (args: WrapArgs): Promise => { + setIsLoading(true); + + try { + const { params, wallet, signTransaction } = args; + const { ownerPublicKey, mint, amount, decimals = 9 } = params; + + const rpc = createRpc(import.meta.env.VITE_HELIUS_RPC_URL); + + const owner = new PublicKey(ownerPublicKey); + const mintPubkey = new PublicKey(mint); + const tokenAmount = BigInt(Math.floor(amount * Math.pow(10, decimals))); + + // Get SPL interface info — determines whether mint uses SPL or T22 + const splInterfaceInfos = await getSplInterfaceInfos(rpc, mintPubkey); + const splInterfaceInfo = splInterfaceInfos.find( + (info) => info.isInitialized, + ); + if (!splInterfaceInfo) throw new Error('No SPL interface found for this mint'); + const { tokenProgram } = splInterfaceInfo; + + // Derive source associated token account using the mint's token program (SPL or T22) + const splAta = getAssociatedTokenAddressSync(mintPubkey, owner, false, tokenProgram); + const ataAccount = await getAccount(rpc, splAta, undefined, tokenProgram); + if (ataAccount.amount < BigInt(tokenAmount)) { + throw new Error('Insufficient SPL balance'); + } + + // Derive light-token associated token account + const lightTokenAta = getAssociatedTokenAddressInterface(mintPubkey, owner); + + // Build transaction + const tx = new Transaction().add( + ComputeBudgetProgram.setComputeUnitLimit({ units: 200_000 }), + createAssociatedTokenAccountInterfaceIdempotentInstruction( + owner, lightTokenAta, owner, mintPubkey, CTOKEN_PROGRAM_ID, + ), + createWrapInstruction( + splAta, lightTokenAta, owner, mintPubkey, + tokenAmount, splInterfaceInfo, decimals, owner, + ), + ); + + const { blockhash } = await rpc.getLatestBlockhash(); + tx.recentBlockhash = blockhash; + tx.feePayer = owner; + + const unsignedTxBuffer = tx.serialize({ requireAllSignatures: false }); + const signedTx = await signTransaction({ + transaction: unsignedTxBuffer, + wallet, + chain: 'solana:devnet', + }); + + const signedTxBuffer = Buffer.from(signedTx.signedTransaction); + return rpc.sendRawTransaction(signedTxBuffer, { + skipPreflight: false, + preflightCommitment: 'confirmed', + }); + } finally { + setIsLoading(false); + } + }; + + return { wrap, isLoading }; +} +``` diff --git a/snippets/setup/register-spl-mint.mdx b/snippets/setup/register-spl-mint.mdx index f6ab4281..57ccead5 100644 --- a/snippets/setup/register-spl-mint.mdx +++ b/snippets/setup/register-spl-mint.mdx @@ -1,4 +1,4 @@ -### One-time: Register an Existing SPL Mint +## One-time: Create interface PDA to existing SPL Mint For existing SPL mints (e.g. USDC), register the SPL interface once. This creates the omnibus PDA that holds SPL tokens when wrapped to light-token. From eb495a435e318eda4eba3b2f1bc215d7c8a7d747 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Mon, 16 Feb 2026 15:52:39 +0000 Subject: [PATCH 22/27] fix privy --- ai-tools/prompts.mdx | 2 +- compressed-tokens/airdrop.mdx | 12 ++----- docs.json | 4 +-- light-token/toolkits/for-privy.mdx | 33 +++++++++++++++--- resources/cli-installation.mdx | 34 +++++++++---------- .../ai-prompts/anchor-programs/light-pda.mdx | 1 - .../code-snippets/privy/balances/nodejs.mdx | 25 ++++---------- .../code-snippets/privy/balances/react.mdx | 30 ++++++---------- 8 files changed, 69 insertions(+), 72 deletions(-) diff --git a/ai-tools/prompts.mdx b/ai-tools/prompts.mdx index 4bbdb2d2..d0fb3581 100644 --- a/ai-tools/prompts.mdx +++ b/ai-tools/prompts.mdx @@ -1,5 +1,5 @@ --- -title: "AI prompts" +title: "AI Prompts" description: "Ready-to-use AI prompts for Light Protocol. Copy a prompt, paste into your AI coding agent, and let it implement the recipe in your project." --- diff --git a/compressed-tokens/airdrop.mdx b/compressed-tokens/airdrop.mdx index aec6b849..72380bcd 100644 --- a/compressed-tokens/airdrop.mdx +++ b/compressed-tokens/airdrop.mdx @@ -19,9 +19,6 @@ import AirdropAiPrompt from "/snippets/ai-prompts/toolkits/airdrop.mdx"; - - - @@ -898,6 +895,9 @@ const recipients = [ + + + # Advanced Features @@ -1056,9 +1056,3 @@ The programs are reference implementations and should be audited before producti - - - - - - diff --git a/docs.json b/docs.json index 5126a337..32fc7a95 100644 --- a/docs.json +++ b/docs.json @@ -164,12 +164,12 @@ "api-reference/sdk", "resources/anchor-constraints", "resources/addresses-and-urls", - "resources/cli-installation", "references/terminology", + "resources/cli-installation", "references/migration-v1-to-v2", "compressed-tokens/overview", - "references/whitepaper", "references/node-operators", + "references/whitepaper", "references/security" ] } diff --git a/light-token/toolkits/for-privy.mdx b/light-token/toolkits/for-privy.mdx index 054b13c4..2c71f8ba 100644 --- a/light-token/toolkits/for-privy.mdx +++ b/light-token/toolkits/for-privy.mdx @@ -97,7 +97,7 @@ const rpc = createRpc(RPC_ENDPOINT); -## Full code examples +## Sign with Privy Find complete examples on GitHub: [Node.js](https://github.com/Lightprotocol/examples-light-token/tree/main/privy/nodejs) and [React](https://github.com/Lightprotocol/examples-light-token/tree/main/privy/react). @@ -163,10 +163,23 @@ Unwrap light-token balance to SPL or Token-2022. Use unwrap to interact with app -## Get balances +## Show Balance -Fetch SOL, hot (light-token ATA), cold (compressed), SPL, and Token-2022 balances. +Query token balances to show a unified balance of SOL, +Light, SPL, and Token-2022. +```typescript +import { + getAssociatedTokenAddressInterface, + getAtaInterface, +} from "@lightprotocol/compressed-token/unified"; + +const ata = getAssociatedTokenAddressInterface(mint, owner); +const account = await getAtaInterface(rpc, ata, owner, mint); +console.log(account.parsed.amount); +``` + + @@ -175,11 +188,22 @@ Fetch SOL, hot (light-token ATA), cold (compressed), SPL, and Token-2022 balance + -## Get transaction history +## Get Transaction History Fetch light-token transaction history for an owner. +```typescript +import { createRpc } from "@lightprotocol/stateless.js"; + +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 +``` + + @@ -188,6 +212,7 @@ Fetch light-token transaction history for an owner. + diff --git a/resources/cli-installation.mdx b/resources/cli-installation.mdx index d8a27652..631a5d4b 100644 --- a/resources/cli-installation.mdx +++ b/resources/cli-installation.mdx @@ -1,6 +1,6 @@ --- -title: "CLI Installation & Commands" -description: "Steps to set up your local environment for ZK Compression development. CLI to interact with compressed accounts and compressed tokens on Solana." +title: "CLI installation & commands" +description: "Steps to set up your local environment for ZK Compression development. CLI to interact with compressed accounts and Light Tokens on Solana." keywords: ["light protocol cli", "zk compression cli"] --- @@ -24,13 +24,13 @@ The CLI will use this wallet as the default fee payer and mint authority. -### Install the ZK Compression CLI +### Install the CLI Ensure you have Node >= v20.9.0 installed on your machine. Windows users do not require WSL. -Run this single command to install the ZK Compression CLI. +Run this single command to install the CLI. ```bash npm i -g @lightprotocol/zk-compression-cli @@ -75,7 +75,7 @@ which light -### Set Up Your Environment +### Set up your environment By default, the CLI interacts with localnet. You can view the current config by running: @@ -149,7 +149,7 @@ solana address # Commands -### Create a compressed token mint +### Create a Light Token mint ```bash light create-mint @@ -170,7 +170,7 @@ FLAGS random keypair. ``` -### Mint compressed tokens to a Solana wallet +### Mint Light Tokens to a Solana wallet ```bash light mint-to --mint "YOUR_MINT_ADDRESS" --to "YOUR_WALLET_ADDRESS" --amount 4200000000 @@ -189,7 +189,7 @@ FLAGS --to= (required) Recipient address. ``` -### Transfer compressed tokens from one wallet to another +### Transfer Light Tokens from one wallet to another ```bash light transfer --mint "YOUR_MINT_ADDRESS" --to "RECIPIENT_WALLET_ADDRESS" --amount 4200000000 @@ -209,33 +209,33 @@ FLAGS ``` -### Assign native SOL to a compressed account +### Wrap SOL into compressed account ```bash -light compress-sol --amount 1000 --to "YOUR_WALLET_ADDRESS_BASE58" +light wrap-sol --amount 1000 --to "YOUR_WALLET_ADDRESS_BASE58" ``` ```bash USAGE - $ light compress-sol --to --amount + $ light wrap-sol --to --amount FLAGS - --amount= (required) Amount to compress in lamports. + --amount= (required) Amount to wrap in lamports. --to= (required) Specify the recipient address. ``` -### Decompress into native SOL +### Unwrap SOL from compressed account ```bash -light decompress-sol --amount 42 --to "YOUR_WALLET_ADDRESS_BASE58" +light unwrap-sol --amount 42 --to "YOUR_WALLET_ADDRESS_BASE58" ``` ```bash USAGE - $ light decompress-sol --to --amount + $ light unwrap-sol --to --amount FLAGS - --amount= (required) Amount to decompress in lamports. + --amount= (required) Amount to unwrap in lamports. --to= (required) Specify the recipient address. ``` @@ -243,7 +243,7 @@ FLAGS (); - - // 1. SPL accounts (standard token program) + // 1. SPL accounts try { const splAccounts = await rpc.getTokenAccountsByOwner(owner, { programId: TOKEN_PROGRAM_ID, @@ -69,31 +66,24 @@ export async function getBalances( // No SPL accounts } - // 2. T22 accounts (Token-2022) — skip Light Token associated token accounts + // 2. Token 2022 accounts try { const t22Accounts = await rpc.getTokenAccountsByOwner(owner, { programId: TOKEN_2022_PROGRAM_ID, }); - for (const {pubkey, account} of t22Accounts.value) { + for (const {account} of t22Accounts.value) { const buf = toBuffer(account.data); if (!buf || buf.length < 72) continue; const mint = new PublicKey(buf.subarray(0, 32)); + const amount = buf.readBigUInt64LE(64); const mintStr = mint.toBase58(); - const expectedAta = getAssociatedTokenAddressInterface(mint, owner); - if (pubkey.equals(expectedAta)) { - // Light Token associated token account — query via getAtaInterface instead - lightAtaMints.add(mintStr); - getOrCreate(mintStr); - } else { - const amount = buf.readBigUInt64LE(64); - getOrCreate(mintStr).t22 += toUiAmount(amount, 9); - } + getOrCreate(mintStr).t22 += toUiAmount(amount, 9); } } catch { // No Token 2022 accounts } - // 3. Hot balance via getAtaInterface (parallelize per mint) + // 3. Hot balance from Light Token associated token account const mintKeys = [...mintMap.keys()]; await Promise.allSettled( mintKeys.map(async (mintStr) => { @@ -108,7 +98,7 @@ export async function getBalances( }), ); - // 4. Cold balance (compressed token accounts — all mints at once) + // 4. Cold balance from compressed token accounts try { const compressed = await rpc.getCompressedTokenBalancesByOwnerV2(owner); for (const item of compressed.value.items) { @@ -148,5 +138,4 @@ function toUiAmount(raw: bigint | {toNumber: () => number}, decimals: number): n } export default getBalances; - ``` diff --git a/snippets/code-snippets/privy/balances/react.mdx b/snippets/code-snippets/privy/balances/react.mdx index b32bf6a7..8792502e 100644 --- a/snippets/code-snippets/privy/balances/react.mdx +++ b/snippets/code-snippets/privy/balances/react.mdx @@ -19,7 +19,7 @@ export interface TokenBalance { unified: bigint; } -export function useLightTokenBalances() { +export function useUnifiedBalance() { const [balances, setBalances] = useState([]); const [isLoading, setIsLoading] = useState(false); @@ -43,9 +43,6 @@ export function useLightTokenBalances() { return entry; }; - // Track which mints we found via T22 light-token ATAs (skip in t22 accumulation) - const lightAtaMints = new Set(); - // 1. SOL balance let solLamports = 0; try { @@ -54,7 +51,7 @@ export function useLightTokenBalances() { // Failed to fetch SOL balance } - // 2. SPL accounts (standard token program) + // 2. SPL accounts try { const splAccounts = await rpc.getTokenAccountsByOwner(owner, { programId: TOKEN_PROGRAM_ID, @@ -71,31 +68,24 @@ export function useLightTokenBalances() { // No SPL accounts } - // 3. T22 accounts (Token-2022) + // 3. Token 2022 accounts try { const t22Accounts = await rpc.getTokenAccountsByOwner(owner, { programId: TOKEN_2022_PROGRAM_ID, }); - for (const { pubkey, account } of t22Accounts.value) { + for (const { account } of t22Accounts.value) { const buf = toBuffer(account.data); if (!buf || buf.length < 72) continue; const mint = new PublicKey(buf.subarray(0, 32)); + const amount = buf.readBigUInt64LE(64); const mintStr = mint.toBase58(); - const expectedAta = getAssociatedTokenAddressInterface(mint, owner); - if (pubkey.equals(expectedAta)) { - // This is a light-token ATA — will query via getAtaInterface instead - lightAtaMints.add(mintStr); - getOrCreate(mintStr); // ensure entry exists for hot balance query - } else { - const amount = buf.readBigUInt64LE(64); - getOrCreate(mintStr).t22 += amount; - } + getOrCreate(mintStr).t22 += amount; } } catch { - // No T22 accounts + // No Token 2022 accounts } - // 4. Hot balance via getAtaInterface (parallelize per mint) + // 4. Hot balance from Light Token associated token account const mintKeys = [...mintMap.keys()]; await Promise.allSettled( mintKeys.map(async (mintStr) => { @@ -106,12 +96,12 @@ export function useLightTokenBalances() { const entry = getOrCreate(mintStr); entry.hot = BigInt(parsed.amount.toString()); } catch { - // ATA does not exist for this mint — hot stays 0n + // Associated token account does not exist for this mint — hot stays 0n } }), ); - // 5. Cold balance (compressed token accounts) + // 5. Cold balance from compressed token accounts try { const compressed = await rpc.getCompressedTokenBalancesByOwnerV2(owner); for (const item of compressed.value.items) { From 837e8936b5c2a05ff24f43a7e724a782108f08dd Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Mon, 16 Feb 2026 16:26:01 +0000 Subject: [PATCH 23/27] fix pill --- style.css | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/style.css b/style.css index d89567fc..f89d0b85 100644 --- a/style.css +++ b/style.css @@ -79,7 +79,7 @@ html.dark .hero-cube-grid { .glass-pill-bg { position: absolute; - inset: -16px -28px; + inset: -20px -28px; z-index: 0; border-radius: 9999px; overflow: hidden; @@ -99,14 +99,14 @@ html.dark .glass-pill-bg { /* Tablet and up - larger pill padding */ @media (min-width: 640px) { .glass-pill-bg { - inset: -18px -44px; + inset: -22px -44px; } } /* Desktop - full pill padding */ @media (min-width: 768px) { .glass-pill-bg { - inset: -22px -64px; + inset: -28px -64px; } } @@ -225,19 +225,45 @@ html.dark .hero-title { display: flex; align-items: center; justify-content: center; - gap: 24px; - margin-top: 8px; + gap: 16px; + margin-top: 6px; pointer-events: none; } .partner-logos img { - height: 24px; + height: 18px; width: auto; } .partner-divider { color: #9ca3af; - font-size: 12px; + font-size: 10px; +} + +@media (min-width: 640px) { + .partner-logos { + gap: 20px; + margin-top: 10px; + } + .partner-logos img { + height: 22px; + } + .partner-divider { + font-size: 11px; + } +} + +@media (min-width: 768px) { + .partner-logos { + gap: 24px; + margin-top: 14px; + } + .partner-logos img { + height: 26px; + } + .partner-divider { + font-size: 12px; + } } /* Light wordmark is white SVG - invert for light mode */ From dd36b213fcd2474ab8559cbaf76e3700b978605d Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Mon, 16 Feb 2026 17:19:00 +0000 Subject: [PATCH 24/27] update pda --- pda/compressed-pdas/overview.mdx | 11 +++++++++-- pda/light-pda/overview.mdx | 7 +++++++ pda/overview.mdx | 13 +++++++++---- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/pda/compressed-pdas/overview.mdx b/pda/compressed-pdas/overview.mdx index 5ba1c935..e714928d 100644 --- a/pda/compressed-pdas/overview.mdx +++ b/pda/compressed-pdas/overview.mdx @@ -20,8 +20,15 @@ to create and update compressed accounts, instead of the System program. Compressed PDAs are compressed accounts with an address. -Use Compressed PDAs to store app and user state or other accounts that are infrequently accessed. -Do not use for shared state, pool accounts, or config accounts. +Compressed PDAs are suited for accounts where each user or entity gets their +own PDA and the total number of accounts is large: +- Per-user state (profiles, preferences, credentials) +- DePIN node accounts and stake accounts +- Nullifiers to prevent an on-chain instruction from +being executed twice (little implementation overhead and useful e.g. for [payments](/pda/compressed-pdas/guides/how-to-create-nullifier-pdas) or [ZK programs](zk/overview)) +- App state that is written to and read from infrequently + +For DeFi pools, vaults, shared state, pool accounts, or config accounts, use [Light-PDA](/pda/light-pda/overview) with minimal code changes. diff --git a/pda/light-pda/overview.mdx b/pda/light-pda/overview.mdx index b2a00336..792bce2d 100644 --- a/pda/light-pda/overview.mdx +++ b/pda/light-pda/overview.mdx @@ -11,6 +11,13 @@ import LightPdaAiPrompt from "/snippets/ai-prompts/anchor-programs/light-pda.mdx |------------------|----------------------|-----------------| | 100-byte account | ~1,600,000 lamports | ~11,500 lamports | +A Light-PDA is a standard Solana PDA. The SDK sponsors rent-exemption so you +don't pay the full rent-exempt balance upfront. Seeds, bump derivation, +`invoke_signed`, and all read/update/close instructions work the same way they +do with regular PDAs. After extended inactivity, the account auto-compresses to +cold state and releases its rent balance. Clients call `create_load_instructions` +to load a cold account back on-chain when it's needed again. + ## What changes Audit overhead is minimal as your program logic is mostly untouched. The rest is macro-generated. diff --git a/pda/overview.mdx b/pda/overview.mdx index 60754708..a5b7d976 100644 --- a/pda/overview.mdx +++ b/pda/overview.mdx @@ -10,12 +10,12 @@ import CompressibleRentExplained from "/snippets/compressible-rent-explained.mdx Light-PDAs are Solana PDAs with sponsored rent-exemption and can be implemented with minimal code changes to your existing Solana program. Your program logic stays mostly untouched, which keeps audit overhead minimal. -> Use like any other PDA, e.g. in your DeFi program. - | | Regular PDA | Light-PDA | |------------------|----------------------|-----------------| | 100-byte account | ~1,600,000 lamports | ~11,500 lamports | +> Use Light-PDA for DeFi pools, vaults, config, and any shared program state. + @@ -30,10 +30,15 @@ Compressed PDAs are compressed accounts with an address. Programs invoke the Light System program to create and update compressed accounts, instead of the System program. Fully compatible with existing Solana programs, but requires custom logic. -> Use for app and user state, or other accounts that are infrequently accessed. - | | Regular PDA | Compressed PDA | |------------------|----------------------|-----------------| | 100-byte account | ~1,600,000 lamports | 15,000 lamports | +> Use for accounts where each user or entity gets their own PDA and the total number of accounts is large: +> - Per-user state (profiles, preferences, credentials) +> - DePIN node accounts and stake accounts +> - Nullifiers to prevent an on-chain instruction from +> being executed twice (little implementation overhead and useful e.g. for [payments](/pda/compressed-pdas/guides/how-to-create-nullifier-pdas) or [ZK programs](zk/overview)) +> - App state that is written to and read from infrequently + \ No newline at end of file From 298e1fcd83a45ec14f55e67431f420dda48810b9 Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Mon, 16 Feb 2026 17:48:55 +0000 Subject: [PATCH 25/27] fix pda --- pda/compressed-pdas/overview.mdx | 5 ++--- pda/light-pda/overview.mdx | 13 +++++++------ pda/overview.mdx | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pda/compressed-pdas/overview.mdx b/pda/compressed-pdas/overview.mdx index e714928d..fab64ad2 100644 --- a/pda/compressed-pdas/overview.mdx +++ b/pda/compressed-pdas/overview.mdx @@ -1,6 +1,6 @@ --- title: Overview & Program Template -description: To store user and app state, or other infrequently accessed state. Compressed PDAs provide full composability and functionality of accounts at PDAs, without rent-exemption per account. +description: Compressed PDAs provide full composability and functionality of accounts at PDAs, without rent-exemption per account. Suited for accounts where each user or entity gets their own PDA and state is infrequently accessed. keywords: ["user state", "app state", "node acounts", "depin accounts", "stake accounts", "not shared state or config or pool accounts", "rent free program derived addresses", "rent free pda accounts", "compressed pda on solana", "infrastructure for depins on solana", "scalable solana infrastructure", "stake accounts for depins", "cost efficient stake accounts", "scalable reward distribution on solana"] --- @@ -20,8 +20,7 @@ to create and update compressed accounts, instead of the System program. Compressed PDAs are compressed accounts with an address. -Compressed PDAs are suited for accounts where each user or entity gets their -own PDA and the total number of accounts is large: +Compressed PDAs are suited for: - Per-user state (profiles, preferences, credentials) - DePIN node accounts and stake accounts - Nullifiers to prevent an on-chain instruction from diff --git a/pda/light-pda/overview.mdx b/pda/light-pda/overview.mdx index 792bce2d..ceefd08d 100644 --- a/pda/light-pda/overview.mdx +++ b/pda/light-pda/overview.mdx @@ -1,6 +1,6 @@ --- title: "Light PDA" -description: "Create Solana PDA accounts with sponsored rent-exemption and minimal code changes. Works with your existing Anchor implementations." +description: "Create Solana PDA accounts with sponsored rent-exemption and minimal code changes. Suited for DeFi pools, vaults, shared state, pool accounts, or config accounts." --- import FullCounterExample from '/snippets/code-snippets/light-token/counter/anchor-macro/full-example.mdx'; @@ -12,11 +12,12 @@ import LightPdaAiPrompt from "/snippets/ai-prompts/anchor-programs/light-pda.mdx | 100-byte account | ~1,600,000 lamports | ~11,500 lamports | A Light-PDA is a standard Solana PDA. The SDK sponsors rent-exemption so you -don't pay the full rent-exempt balance upfront. Seeds, bump derivation, -`invoke_signed`, and all read/update/close instructions work the same way they -do with regular PDAs. After extended inactivity, the account auto-compresses to -cold state and releases its rent balance. Clients call `create_load_instructions` -to load a cold account back on-chain when it's needed again. +don't pay the full rent-exempt balance upfront. Seeds, bump derivation, and +`invoke_signed` work the same way. Your instruction handlers for reads, +updates, and closes don't change. After extended inactivity, the account +compresses to cold state and returns the rent-exempt balance to the rent +sponsor. Clients call `create_load_instructions` to load a cold account back +on-chain when it's needed again. ## What changes diff --git a/pda/overview.mdx b/pda/overview.mdx index a5b7d976..5995342d 100644 --- a/pda/overview.mdx +++ b/pda/overview.mdx @@ -34,7 +34,7 @@ Fully compatible with existing Solana programs, but requires custom logic. |------------------|----------------------|-----------------| | 100-byte account | ~1,600,000 lamports | 15,000 lamports | -> Use for accounts where each user or entity gets their own PDA and the total number of accounts is large: +> Use for accounts where each user or entity gets their own PDA and state is infrequently accessed: > - Per-user state (profiles, preferences, credentials) > - DePIN node accounts and stake accounts > - Nullifiers to prevent an on-chain instruction from From 01d2ae7647e48cf2b73772e96f4f0b93e7b5146b Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Mon, 16 Feb 2026 18:19:38 +0000 Subject: [PATCH 26/27] pda --- pda/light-pda/overview.mdx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pda/light-pda/overview.mdx b/pda/light-pda/overview.mdx index ceefd08d..49053100 100644 --- a/pda/light-pda/overview.mdx +++ b/pda/light-pda/overview.mdx @@ -11,13 +11,9 @@ import LightPdaAiPrompt from "/snippets/ai-prompts/anchor-programs/light-pda.mdx |------------------|----------------------|-----------------| | 100-byte account | ~1,600,000 lamports | ~11,500 lamports | -A Light-PDA is a standard Solana PDA. The SDK sponsors rent-exemption so you -don't pay the full rent-exempt balance upfront. Seeds, bump derivation, and +A Light-PDA is a standard Solana PDA. Seeds, bump derivation, and `invoke_signed` work the same way. Your instruction handlers for reads, -updates, and closes don't change. After extended inactivity, the account -compresses to cold state and returns the rent-exempt balance to the rent -sponsor. Clients call `create_load_instructions` to load a cold account back -on-chain when it's needed again. +updates, and closes don't change. ## What changes @@ -165,10 +161,11 @@ View counter example on Github: [counter](https://github.com/Lightprotocol/examp ## How it works -The SDK pays the rent-exemption cost. After extended inactivity, cold accounts -auto-compress. Your program only ever interacts with hot accounts. Clients can -safely load cold accounts back into the onchain Solana account space when needed -via `create_load_instructions`. +The SDK sponsors rent-exemption so you +don't pay the full rent-exempt balance upfront. After extended inactivity, the account +compresses to cold state and returns the rent-exempt balance to the rent +sponsor. Clients call `create_load_instructions` to load a cold account back +on-chain when it's needed again. Your program only ever interacts with hot accounts. | | Hot (active) | Cold (inactive) | |---|---|---| From 4fe762848ba0aaf4d4cffc068967e687516ae02b Mon Sep 17 00:00:00 2001 From: tilo-14 Date: Mon, 16 Feb 2026 18:37:23 +0000 Subject: [PATCH 27/27] update quickstart --- light-token/quickstart.mdx | 26 ++--- quickstart.mdx | 101 ------------------ .../light-token/mint-spl-and-wrap/action.mdx | 96 +++++++++++++++++ 3 files changed, 104 insertions(+), 119 deletions(-) delete mode 100644 quickstart.mdx create mode 100644 snippets/code-snippets/light-token/mint-spl-and-wrap/action.mdx diff --git a/light-token/quickstart.mdx b/light-token/quickstart.mdx index af9fdc75..d0ecf983 100644 --- a/light-token/quickstart.mdx +++ b/light-token/quickstart.mdx @@ -1,12 +1,12 @@ --- title: Quickstart -description: Mint tokens to a Light-ATA in under 3 minutes. +description: Mint SPL tokens, wrap to Light Token, and transfer in under 3 minutes. sidebarTitle: Quickstart keywords: ["create tokens on solana tutorial", "mint tokens on solana guide", "spl token quickstart for developers", "token sdk for solana apps"] --- import FullSetup from "/snippets/setup/full-setup.mdx"; -import MintToAction from "/snippets/code-snippets/light-token/mint-to/action.mdx"; +import MintSplAndWrapAction from "/snippets/code-snippets/light-token/mint-spl-and-wrap/action.mdx"; import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; @@ -21,31 +21,21 @@ import AgentSkillGeneric from "/snippets/setup/agent-skill-generic.mdx"; -## Mint Tokens to Light-ATA +## Mint SPL tokens, convert to Light Token and Transfer - + # Next Steps - - Guides for dedicated use cases + Find answers to frequently answered questions. - - Step-by-step recipes - - - diff --git a/quickstart.mdx b/quickstart.mdx deleted file mode 100644 index f02837fa..00000000 --- a/quickstart.mdx +++ /dev/null @@ -1,101 +0,0 @@ ---- -title: Quickstart -description: Create your first compressed tokens in under 5 minutes. -sidebarTitle: Quickstart -keywords: ["zk compression quickstart", "compressed accounts tutorial", "solana compression guide"] ---- - -import FullSetup from "/snippets/setup/full-setup.mdx"; - - - - -## Prerequisites - - - - - -## Mint Compressed Tokens - -```typescript -// 1. Load wallet and connect to Localnet -// 2. Create SPL mint with SPL interface via createMint() -// 3. Mint compressed tokens to recipient account via mintTo() -// 4. Verify compressed token balance via getCompressedTokenAccountsByOwner - -import { createRpc } from "@lightprotocol/stateless.js"; -import { createMint, mintTo } from "@lightprotocol/compressed-token"; -import { Keypair } from "@solana/web3.js"; -import { readFileSync } from "fs"; -import { homedir } from "os"; - -// Step 1: Load wallet from filesystem -const payer = Keypair.fromSecretKey( - new Uint8Array(JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8"))) -); - -// Connect to local test-validator -const RPC_ENDPOINT = "http://localhost:8899"; -const COMPRESSION_ENDPOINT = "http://localhost:8784"; -const PROVER_ENDPOINT = "http://localhost:3001"; -const connection = createRpc(RPC_ENDPOINT, COMPRESSION_ENDPOINT, PROVER_ENDPOINT); - -const main = async () => { - try { - // Step 2: Create SPL mint with SPL interface - console.log("\nCreating SPL mint with SPL interface for compression"); - const { mint, transactionSignature } = await createMint( - connection, - payer, - payer.publicKey, // mintAuthority - 9 - ); - - console.log(`Mint address: ${mint.toBase58()}`); - console.log( - `Create mint transaction: https://explorer.solana.com/tx/${transactionSignature}?cluster=custom&customUrl=http://localhost:8899` - ); - - // Step 3: Mint compressed tokens to recipient account - console.log("\nMinting compressed token..."); - const mintAmount = 1000000000; // mintAmount with decimals - const mintToTxId = await mintTo( - connection, - payer, - mint, // SPL mint with SPL interface for compression - payer.publicKey, // recipient.publicKey - payer, // mintAuthority - mintAmount - ); - - console.log(`Compressed Token minted ${mintAmount / 1e9} token`); - console.log( - `Transaction: https://explorer.solana.com/tx/${mintToTxId}?cluster=custom&customUrl=http://localhost:8899` - ); - - // Step 4: Verify compressed token balance via getCompressedTokenAccountsByOwner - const tokenAccounts = await connection.getCompressedTokenAccountsByOwner( - payer.publicKey, - { mint } // SPL mint with SPL interface for compression - ); - } catch (error: any) { - console.error("Error:", error.message); - } -}; - -main().catch(console.error); -``` - - - - -# Next Steps - - diff --git a/snippets/code-snippets/light-token/mint-spl-and-wrap/action.mdx b/snippets/code-snippets/light-token/mint-spl-and-wrap/action.mdx new file mode 100644 index 00000000..c7912507 --- /dev/null +++ b/snippets/code-snippets/light-token/mint-spl-and-wrap/action.mdx @@ -0,0 +1,96 @@ +```typescript +import "dotenv/config"; +import { Keypair, PublicKey } from "@solana/web3.js"; +import { createRpc } from "@lightprotocol/stateless.js"; +import { + createMintInterface, + createAtaInterfaceIdempotent, + getAssociatedTokenAddressInterface, + wrap, + transferInterface, +} from "@lightprotocol/compressed-token"; +import { + TOKEN_2022_PROGRAM_ID, + createAssociatedTokenAccount, + mintTo, +} from "@solana/spl-token"; +import { homedir } from "os"; +import { readFileSync } from "fs"; + +// devnet: +const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`; +const rpc = createRpc(RPC_URL); +// localnet: +// const rpc = createRpc(); + +const payer = Keypair.fromSecretKey( + new Uint8Array( + JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8")) + ) +); + +(async function () { + const decimals = 9; + const tokenAmount = BigInt(100 * Math.pow(10, decimals)); + const recipient = Keypair.generate(); + + // Creates on-chain SPL or Token-2022 mint and registers SPL interface PDA. + // SPL interface PDA enables wrap/unwrap between SPL/Token-2022 and Light Token. + const mintKeypair = Keypair.generate(); + const { mint } = await createMintInterface( + rpc, + payer, + payer, + null, + decimals, + mintKeypair, + undefined, + TOKEN_2022_PROGRAM_ID, + ); + + // 1. Mint SPL tokens to payer's associated token account + const payerSplAta = await createAssociatedTokenAccount( + rpc, + payer, + mint, + payer.publicKey, + undefined, + TOKEN_2022_PROGRAM_ID, + ); + await mintTo( + rpc, + payer, + mint, + payerSplAta, + payer, + tokenAmount, + [], + undefined, + TOKEN_2022_PROGRAM_ID, + ); + + // 2. Wrap SPL tokens into payer's light associated token account + await createAtaInterfaceIdempotent(rpc, payer, mint, payer.publicKey); + const payerLightAta = getAssociatedTokenAddressInterface(mint, payer.publicKey); + await wrap(rpc, payer, payerSplAta, payerLightAta, payer, mint, tokenAmount); + + // 3. Transfer to recipient's light associated token account + await createAtaInterfaceIdempotent(rpc, payer, mint, recipient.publicKey); + const recipientLightAta = getAssociatedTokenAddressInterface(mint, recipient.publicKey); + await transferInterface( + rpc, + payer, + payerLightAta, + mint, + recipientLightAta, + payer, + tokenAmount, + ); + + console.log("Transferred", 100, "tokens to", recipient.publicKey.toBase58()); +})(); +``` + + +Source: [mint-spl-and-wrap.ts](https://github.com/Lightprotocol/examples-light-token/blob/main/toolkits/sign-with-privy/scripts/src/mint-spl-and-wrap.ts) +