Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .context/program-examples
Submodule program-examples deleted from bf2705
46 changes: 46 additions & 0 deletions .github/workflows/sync-examples-light-token.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Sync Examples Light Token

on:
repository_dispatch:
types: [sync-examples-light-token]
workflow_dispatch:

jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout docs repo
uses: actions/checkout@v4

- name: Checkout examples repo
uses: actions/checkout@v4
with:
repository: Lightprotocol/examples-light-token
path: examples-light-token
ref: ${{ github.event.client_payload.commit || 'main' }}

- name: Run snippet sync scripts
env:
EXAMPLES_LIGHT_TOKEN: ${{ github.workspace }}/examples-light-token
run: |
chmod +x ./scripts/copy-light-token-snippets.sh
chmod +x ./scripts/copy-rust-snippets.sh
chmod +x ./scripts/copy-program-snippets.sh
chmod +x ./scripts/copy-sponsor-top-ups-snippets.sh

./scripts/copy-light-token-snippets.sh
./scripts/copy-rust-snippets.sh
./scripts/copy-program-snippets.sh
./scripts/copy-sponsor-top-ups-snippets.sh
Comment on lines +25 to +34

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 GitHub Actions workflow calls scripts with hardcoded local paths that will fail in CI

The new sync-examples-light-token.yml workflow sets EXAMPLES_LIGHT_TOKEN as an environment variable and calls four scripts. Only copy-sponsor-top-ups-snippets.sh (new in this PR) correctly uses ${EXAMPLES_LIGHT_TOKEN:?...}. The other three scripts (copy-light-token-snippets.sh, copy-rust-snippets.sh, copy-program-snippets.sh) use hardcoded paths like /home/tilo/Workspace/... which don't exist on the CI runner.

Root Cause

The workflow at .github/workflows/sync-examples-light-token.yml:23-34 sets EXAMPLES_LIGHT_TOKEN: ${{ github.workspace }}/examples-light-token and calls all four scripts. However:

  • scripts/copy-light-token-snippets.sh:6 uses EXAMPLES="/home/tilo/Workspace/streaming-tokens/typescript-client"
  • scripts/copy-rust-snippets.sh:6 uses EXAMPLES_DIR="/home/tilo/Workspace/examples-light-token/rust-client"
  • scripts/copy-program-snippets.sh:12 uses ANCHOR_EXAMPLES_DIR="/home/tilo/Workspace/examples-light-token-anchor/programs/anchor/basic-instructions"

When the workflow runs on ubuntu-latest, these paths don't exist, and cat / file operations will fail. The workflow will never successfully sync snippets.

Impact: The automated snippet sync workflow will fail every time it runs (on repository_dispatch or workflow_dispatch), silently preventing docs from staying in sync with the examples repo.

Prompt for agents
The three scripts called by the workflow (copy-light-token-snippets.sh, copy-rust-snippets.sh, copy-program-snippets.sh) use hardcoded local paths like /home/tilo/Workspace/... instead of the EXAMPLES_LIGHT_TOKEN environment variable set by the workflow. Update each script to use the EXAMPLES_LIGHT_TOKEN env var, following the pattern already used in copy-sponsor-top-ups-snippets.sh line 10: SRC="${EXAMPLES_LIGHT_TOKEN:?Set EXAMPLES_LIGHT_TOKEN to examples-light-token repo root}/...". Specifically:

1. scripts/copy-light-token-snippets.sh line 6: Replace hardcoded EXAMPLES path with ${EXAMPLES_LIGHT_TOKEN}/typescript-client (or appropriate subpath) and line 7: Replace SNIPPETS_DIR with a relative path from SCRIPT_DIR.
2. scripts/copy-rust-snippets.sh line 6-7: Same pattern - use ${EXAMPLES_LIGHT_TOKEN}/rust-client and relative SNIPPETS_DIR.
3. scripts/copy-program-snippets.sh lines 6, 12, 85: Same pattern - use ${EXAMPLES_LIGHT_TOKEN}/programs/anchor/basic-instructions and relative SNIPPETS_DIR.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
branch: auto-sync/examples-light-token
delete-branch: true
title: "chore: sync code snippets from examples-light-token"
commit-message: "chore: sync snippets from examples-light-token@${{ github.event.client_payload.commit || 'manual' }}"
body: |
Auto-generated by [sync workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).

Source commit: Lightprotocol/examples-light-token@${{ github.event.client_payload.commit || 'manual dispatch' }}
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ mintlify-docs/
/CLAUDE.md
.windsurf.context/
.claude/
.entire/

# Dependencies
node_modules/

stash
.reapply-stash/
docs-audit.md
docs-audit.txt
docs-audit.txt
docs-anchor.json
product-docs.json
tabs-docs.json
1 change: 1 addition & 0 deletions .mintlifyignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
.entire/
ai-tools/skills/
ai-tools/prompts/
ai-tools/.claude-plugin/
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Resources for developers to learn and build:

- **Light-Token Program**: High performance token program that reduces the cost of account creations by 200x, while being more CU efficient than SPL on hot paths.
- **ZK Compression Core**: Solana account primitive that lets you create tokens and PDAs without rent-exemption cost with L1 performance and security.

Resources for developers to learn and build:
* **Light-Token Program**: High performance token program that reduces the cost of account creations by 200x, while being more CU efficient than SPL on hot paths.
* **ZK Compression Core**: Solana account primitive that lets you create tokens and PDAs without rent-exemption with L1 performance and security.
---

Find more resources here:
* Documentation: [zkcompression.com](https://www.zkcompression.com).
* [Examples](https://github.com/Lightprotocol/examples-light-token)
* [Agent Skills](https://github.com/Lightprotocol/skills/tree/main)

- Documentation: [zkcompression.com](https://www.zkcompression.com).
- [Examples](https://github.com/Lightprotocol/examples-light-token)
- [Agent Skills](https://github.com/Lightprotocol/skills/tree/main)
55 changes: 34 additions & 21 deletions ai-tools/guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,51 @@
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

- **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

### `skill.md`
## Agent Skills

`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.
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.

* View: [`/skill.md`](https://zkcompression.com/skill.md)
Install or view dedicated agent skills:

### `llms.txt`
| Use case | Skill |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
| Build rent-free Solana programs with Light SDK (Anchor or Pinocchio). Includes router integration. | [light-sdk](https://github.com/Lightprotocol/skills/tree/main/skills/light-sdk) |
| Use Light Token client SDKs (TypeScript and Rust) for mints, ATAs, transfers | [light-token-client](https://github.com/Lightprotocol/skills/tree/main/skills/light-token-client) |
| 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 | [token-distribution](https://github.com/Lightprotocol/skills/tree/main/skills/token-distribution) |
| 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) |
| For per-user state, DePIN nodes, and infrequently accessed app state with compressed PDAs | [solana-compression](https://github.com/Lightprotocol/skills/tree/main/skills/solana-compression) |
| Help with Debugging and Questions via DeepWiki MCP | [ask-mcp](https://github.com/Lightprotocol/skills/tree/main/skills/ask-mcp) |

`llms.txt` is an index of the docs. It lists key pages with descriptions
so agents can navigate to answers quickly.
> View all skills here: https://github.com/Lightprotocol/skills.

* 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`
<InstallAgentSkills />

`llms-full.txt` is the full, expanded index for agents that want complete coverage of the documentation.
## AI Prompts

* View: [`/llms-full.txt`](https://zkcompression.com/llms-full.txt)
<Card
title="Find ready-to-use AI prompts for your agent here and all guides. "
icon="chevron-right"
color="#0066ff"
href="/ai-tools/prompts"
horizontal
/>

## MCP

Expand Down Expand Up @@ -175,14 +190,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).
</Tip>

<div style={{ display: 'flex', alignItems: 'center', gap: '0.5em' }}>
<h3 style={{ margin: 0 }}>Alternative: DeepWiki Web</h3>
<a href="https://deepwiki.com/Lightprotocol/light-protocol" style={{ margin: 0 }}>
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki" style={{ marginTop: 0, marginBottom: 0, verticalAlign: 'middle' }} />
</a>
</div>
<Accordion title="Alternative: DeepWiki Web">

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.

<Frame>
<iframe
Expand All @@ -196,3 +206,6 @@ If you don't have the MCP installed we recommend to use AskDevin in your browser
allowfullscreen
></iframe>
</Frame>

</Accordion>

8 changes: 8 additions & 0 deletions ai-tools/prompts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
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 AllPrompts from "/snippets/ai-prompts/all-prompts.mdx";

<AllPrompts />
194 changes: 194 additions & 0 deletions api-reference/anchor.mdx
Original file line number Diff line number Diff line change
@@ -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 + <Counter as anchor_lang::Space>::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)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Capitalize "GitHub" correctly (applies to lines 39, 73, 101, 165).

The official spelling uses a capital "H". This appears four times in the file.

-Examples: [Github](https://github.com/...
+Examples: [GitHub](https://github.com/...
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Examples: [Github](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter)
Examples: [GitHub](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-macros/counter)
🧰 Tools
🪛 LanguageTool

[uncategorized] ~39-~39: The official name of this software platform is spelled with a capital “H”.
Context: ...ccount<'info, Counter>, ``` Examples: [Github](https://github.com/Lightprotocol/examp...

(GITHUB)

🤖 Prompt for AI Agents
In `@resources/anchor-constraints.mdx` at line 39, Replace the incorrect "Github"
spelling with the official "GitHub" in this document; locate the visible link
text "Github" in the Examples link (the anchor text for
https://github.com/Lightprotocol/examples-light-token/…) and update it, and also
search the file for the other occurrences of "Github" (the other two instances
referenced in the review) and change them to "GitHub" so all four usages use the
correct capitalization.


---

### `#[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 = <seeds>,
token::mint = <account>,
token::owner = <account>,
token::bump = <expr>
)]
```

```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 = <account>,
associated_token::mint = <account>,
associated_token::bump = <expr>
)]
```

```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 = <account>,
mint::authority = <account>,
mint::decimals = <expr>,
mint::seeds = <seeds>,
)]
```

**attribute (optional)**

```
mint::bump = <expr>
mint::freeze_authority = <ident>
mint::authority_seeds = <seeds>
mint::name = <expr> // requires symbol + uri
mint::symbol = <expr> // requires name + uri
mint::uri = <expr> // requires name + symbol
mint::update_authority = <ident> // requires name, symbol, uri
mint::additional_metadata = <expr> // 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>,
```

<Accordion title="Mint with metadata">

```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>,
```

</Accordion>

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.

<Tabs>
<Tab title="PDA">

| 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. |

</Tab>
<Tab title="Token / ATA / Mint">

| 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. |

</Tab>
</Tabs>
Loading