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
67 changes: 67 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Setup Environment
description: Setup Rust, Solana CLI, and Light CLI for testing

inputs:
solana-cli-version:
description: "Solana CLI version"
required: false
default: "2.1.21"
rust-toolchain:
description: "Rust toolchain version"
required: false
default: "1.85.0"
light-cli-version:
description: "Light CLI version"
required: false
default: "alpha"

runs:
using: composite
steps:
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ inputs.rust-toolchain }}
cache: false

- name: Setup Node.js (for Light CLI)
uses: actions/setup-node@v4
with:
node-version: "22"

- name: Cache npm global packages
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-light-cli-${{ inputs.light-cli-version }}

- name: Cache Solana CLI tools
uses: actions/cache@v4
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-cli-${{ runner.os }}-${{ inputs.solana-cli-version }}

- name: Install Solana CLI tools
shell: bash
run: |
sh -c "$(curl -sSfL https://release.anza.xyz/v${{ inputs.solana-cli-version }}/install)"
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH

- name: Install Light CLI
shell: bash
run: npm install -g @lightprotocol/zk-compression-cli@${{ inputs.light-cli-version }}

- name: Generate keypair
shell: bash
run: solana-keygen new --no-bip39-passphrase

- name: Display versions
shell: bash
run: |
rustc --version
cargo --version
solana --version
light --version

85 changes: 85 additions & 0 deletions .github/workflows/typescript-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: TypeScript

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
SOLANA_CLI_VERSION: "2.1.21"
NODE_VERSION: "22"

jobs:
typescript-tests:
name: TypeScript Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Cache Solana CLI tools
uses: actions/cache@v4
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-cli-${{ runner.os }}-${{ env.SOLANA_CLI_VERSION }}

- name: Install Solana CLI tools
run: |
sh -c "$(curl -sSfL https://release.anza.xyz/v${{ env.SOLANA_CLI_VERSION }}/install)"
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH

- name: Install Light CLI
run: npm install -g @lightprotocol/zk-compression-cli@alpha

- name: Install Rust (for Photon)
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: false

- name: Cache Photon indexer
id: cache-photon
uses: actions/cache@v4
with:
path: ~/.cargo/bin/photon
key: photon-${{ runner.os }}-1a785036de52896b68d06413e3b0231122d6aa4a

- name: Install Photon indexer
if: steps.cache-photon.outputs.cache-hit != 'true'
run: cargo install --git https://github.com/lightprotocol/photon.git --rev 1a785036de52896b68d06413e3b0231122d6aa4a --locked
env:
RUSTFLAGS: "-A dead-code"

- name: Generate keypair
run: solana-keygen new --no-bip39-passphrase

- name: Install dependencies
working-directory: typescript-client
run: npm install

- name: Start test validator
run: |
light test-validator &
sleep 15

- name: Run actions
working-directory: typescript-client
run: npm run test:actions

- name: Run instructions
working-directory: typescript-client
run: npm run test:instructions
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
**/pnpm-lock.yaml
**/package-lock.json
**/*.json.bak
**/test-ledger
**/test-ledger
**/target
cli/accounts/
100 changes: 27 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,85 +1,39 @@
# Light Token Examples
## Quickstart

### [Devnet Quickstart](devnet-quickstart/)
Light token is a high-performance token standard that reduces the cost of mint and token accounts by 200x.

End-to-end example: create a mint, token account, mint tokens, and transfer on devnet.
* All light mint and token accounts are on-chain accounts like SPL, but the light token program sponsors the rent-exemption cost for you.
* Light-token accounts can hold balances from any light, SPL, or Token-2022 mint.
* Light-mint accounts represent a unique mint and optionally can store token-metadata. Functionally equivalent to SPL mints.

## Cookbook
### Toolkits

Step-by-step recipes for light-token on Devnet/Localnet.
- **[Payments and Wallets](toolkits/payments-and-wallets/)** - All you need for wallet integrations and payment flows. Minimal API differences to SPL.
- **[Streaming Tokens](toolkits/streaming-tokens/)** - Stream mint events using Laserstream

### [Actions](cookbook/actions/)
### TypeScript Client

- **[create-mint](cookbook/actions/create-mint.ts)** - Create a new light-token mint
- **[create-ata](cookbook/actions/create-ata.ts)** - Create an associated light-token account
- **[load-ata](cookbook/actions/load-ata.ts)** - Load a cold token account (compressed) to hot balance (light-token ata)
- **[mint-to](cookbook/actions/mint-to.ts)** - Mint tokens to a light-account
- **[transfer-interface](cookbook/actions/transfer-interface.ts)** - Transfer tokens between light-token, T22, and SPL token accounts.
- **[wrap](cookbook/actions/wrap.ts)** - Wrap SPL to light-token
- **[unwrap](cookbook/actions/unwrap.ts)** - Unwrap light-token to SPL for off-ramps and legacy integrations
TypeScript examples for light-token-sdk.

### [Instructions](cookbook/instructions/)

Low-level instruction builders:

- **[create-mint](cookbook/instructions/create-mint.ts)** - Build create mint instruction
- **[create-ata](cookbook/instructions/create-ata.ts)** - Build create ATA instruction
- **[load-ata](cookbook/instructions/load-ata.ts)** - Build load ATA instruction
- **[mint-to](cookbook/instructions/mint-to.ts)** - Build mint-to instruction
- **[transfer-interface](cookbook/instructions/transfer-interface.ts)** - Build transfer interface instruction for transfers between light-token, T22, and SPL token accounts.
- **[wrap](cookbook/instructions/wrap.ts)** - Build wrap instruction
- **[unwrap](cookbook/instructions/unwrap.ts)** - Build unwrap instruction for off-ramps and legacy integrations

## Toolkits

### [Payments and Wallets](toolkits/payments-and-wallets/)

Examples for wallet integrations and payment flows:

- **[get-balance](toolkits/payments-and-wallets/get-balance.ts)** - Fetch token balances for light-token accounts
- **[get-history](toolkits/payments-and-wallets/get-history.ts)** - Fetch transaction history for light-token accounts
- **[send-and-receive](toolkits/payments-and-wallets/send-and-receive.ts)** - Send and receive light-tokens using the transfer interface
- **[wrap](toolkits/payments-and-wallets/wrap.ts)** - Wrap SPL tokens to light-token
- **[unwrap](toolkits/payments-and-wallets/unwrap.ts)** - Unwrap light-token to SPL for off-ramps and legacy integrations

### [Streaming Tokens](toolkits/streaming-tokens/)

Rust program example with test to stream mint events of the Light-Token Program.


## Setup

```bash
npm install @lightprotocol/stateless.js@alpha \
@lightprotocol/compressed-token@alpha
```

```bash
cp .env.example .env # ...and set RPC_URL
```

## Run

From repo root:

```bash
# quickstart
npm run quickstart

# cookbook (local)
npm run cookbook create-mint:action
npm run cookbook compress:action
# ... see cookbook/package.json for more

# payments
npm run toolkit:payments send-and-receive
```


For local net, install via `npm i -g @lightprotocol/zk-compression-cli@alpha`, then run `light test-validator` in a separate terminal.
- **create-mint** - Create a light-token mint
- [Action](typescript-client/actions/create-mint.ts) | [Instruction](typescript-client/instructions/create-mint.ts)
- **create-ata** - Create an associated light-token account
- [Action](typescript-client/actions/create-ata.ts) | [Instruction](typescript-client/instructions/create-ata.ts)
- **load-ata** - Load cold token account to hot balance
- [Action](typescript-client/actions/load-ata.ts) | [Instruction](typescript-client/instructions/load-ata.ts)
- **mint-to** - Mint tokens to a light-account
- [Action](typescript-client/actions/mint-to.ts) | [Instruction](typescript-client/instructions/mint-to.ts)
- **transfer-interface** - Transfer between light-token, T22, and SPL accounts
- [Action](typescript-client/actions/transfer-interface.ts) | [Instruction](typescript-client/instructions/transfer-interface.ts)
- **wrap** - Wrap SPL/T22 to light-token
- [Action](typescript-client/actions/wrap.ts)
- **unwrap** - Unwrap light-token to SPL/T22
- [Action](typescript-client/actions/unwrap.ts)
- **delegate-approve** - Approve delegate
- [Action](typescript-client/actions/delegate-approve.ts)
- **delegate-revoke** - Revoke delegate
- [Action](typescript-client/actions/delegate-revoke.ts)

## Documentation

Learn more [about to Light-Token here](https://www.zkcompression.com/light-token/welcome).

38 changes: 0 additions & 38 deletions cookbook/actions/compress-batch.ts

This file was deleted.

36 changes: 0 additions & 36 deletions cookbook/actions/compress.ts

This file was deleted.

Loading
Loading