Skip to content
Open
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
59 changes: 59 additions & 0 deletions .github/workflows/rust-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Rust

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.3.11"
RUST_TOOLCHAIN: "1.90.0"

jobs:
test-rust:
name: ${{ matrix.package }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package:
# basic-instructions
- light-token-anchor-approve
- light-token-anchor-burn
- light-token-anchor-close
- light-token-anchor-create-associated-token-account
- light-token-anchor-create-mint
- light-token-anchor-create-token-account
- light-token-anchor-freeze
- light-token-anchor-mint-to
- light-token-anchor-revoke
- light-token-anchor-thaw
- light-token-anchor-transfer-checked
- light-token-anchor-transfer-interface
# basic-macros
- counter
- light-token-macro-create-associated-token-account
- light-token-macro-create-mint
- light-token-macro-create-token-account
- create-and-transfer
steps:
- uses: actions/checkout@v4

- name: Setup environment
uses: ./.github/actions/setup
with:
example: programs/anchor
solana-cli-version: ${{ env.SOLANA_CLI_VERSION }}
rust-toolchain: ${{ env.RUST_TOOLCHAIN }}

- name: Test
working-directory: programs/anchor
run: cargo test-sbf -p ${{ matrix.package }}
5 changes: 4 additions & 1 deletion .github/workflows/typescript-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ jobs:
- name: Start test validator
run: |
light test-validator &
sleep 15
for i in $(seq 1 60); do
curl -s http://127.0.0.1:8784/health && break
sleep 2
done

- name: Run actions
working-directory: typescript-client
Expand Down
157 changes: 81 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,82 +8,87 @@ Light token is a high-performance token standard that reduces the cost of mint a

## Toolkits

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

## TypeScript Client

* **create-mint** - Create a light-token mint with metadata
* [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 token accounts from light-token, compressed tokens, SPL/T22 to one unified 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) | [Instruction](typescript-client/instructions/wrap.ts)
* **unwrap** - Unwrap light-token to SPL/T22
* [Action](typescript-client/actions/unwrap.ts) | [Instruction](typescript-client/instructions/unwrap.ts)
* **delegate-approve** - Approve delegate
* [Action](typescript-client/actions/delegate-approve.ts)
* **delegate-revoke** - Revoke delegate
* [Action](typescript-client/actions/delegate-revoke.ts)

## Rust Client

* **create-mint** - Create a light-token mint with metadata
* [Action](rust-client/actions/create_mint.rs) | [Instruction](rust-client/instructions/create_mint.rs)
* **create-ata** - Create an associated light-token account
* [Action](rust-client/actions/create_ata.rs) | [Instruction](rust-client/instructions/create_ata.rs)
* **create-token-account** - Create a light-token account with custom owner
* [Instruction](rust-client/instructions/create_token_account.rs)
* **mint-to** - Mint tokens to a light-account
* [Action](rust-client/actions/mint_to.rs) | [Instruction](rust-client/instructions/mint_to.rs)
* **mint-to-checked** - Mint tokens with decimal validation
* [Instruction](rust-client/instructions/mint_to_checked.rs)
* **transfer-interface** - Transfer between light-token, T22, and SPL accounts
* [Action](rust-client/actions/transfer_interface.rs) | [Instruction](rust-client/instructions/transfer_interface.rs)
* **transfer-checked** - Transfer with decimal validation
* [Action](rust-client/actions/transfer_checked.rs) | [Instruction](rust-client/instructions/transfer_checked.rs)
* **spl-to-light-transfer** - Transfer from SPL to Light via TransferInterface
* [Instruction](rust-client/instructions/spl_to_light_transfer.rs)
* **wrap** - Wrap SPL/T22 to light-token
* [Action](rust-client/actions/wrap.rs)
* **unwrap** - Unwrap light-token to SPL/T22
* [Action](rust-client/actions/unwrap.rs)
* **burn** - Burn tokens
* [Instruction](rust-client/instructions/burn.rs)
* **burn-checked** - Burn tokens with decimal validation
* [Instruction](rust-client/instructions/burn_checked.rs)
* **approve** - Approve delegate
* [Action](rust-client/actions/approve.rs) | [Instruction](rust-client/instructions/approve.rs)
* **revoke** - Revoke delegate
* [Action](rust-client/actions/revoke.rs) | [Instruction](rust-client/instructions/revoke.rs)
* **freeze** - Freeze a token account
* [Instruction](rust-client/instructions/freeze.rs)
* **thaw** - Thaw a frozen token account
* [Instruction](rust-client/instructions/thaw.rs)
* **close** - Close a token account
* [Instruction](rust-client/instructions/close.rs)

## Run

```bash
# TypeScript
cd typescript-client
npm run create-mint:action
npm run mint-to:action
# See package.json for all scripts

# Rust
cd rust-client
cargo run --example action_create_mint
cargo run --example instruction_mint_to_checked
```
| | Description |
|---------|-------------|
| [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 |

## Client Examples

### TypeScript

| | | | Description |
|---------|--------|-------------|-------------|
| create-mint | [Action](typescript-client/actions/create-mint.ts) | [Instruction](typescript-client/instructions/create-mint.ts) | Create a light-token mint with metadata |
| create-ata | [Action](typescript-client/actions/create-ata.ts) | [Instruction](typescript-client/instructions/create-ata.ts) | Create an associated light-token account |
| load-ata | [Action](typescript-client/actions/load-ata.ts) | [Instruction](typescript-client/instructions/load-ata.ts) | Load token accounts from light-token, compressed tokens, SPL/T22 to one unified balance |
| mint-to | [Action](typescript-client/actions/mint-to.ts) | [Instruction](typescript-client/instructions/mint-to.ts) | Mint tokens to a light-account |
| transfer-interface | [Action](typescript-client/actions/transfer-interface.ts) | [Instruction](typescript-client/instructions/transfer-interface.ts) | Transfer between light-token, T22, and SPL accounts |
| wrap | [Action](typescript-client/actions/wrap.ts) | [Instruction](typescript-client/instructions/wrap.ts) | Wrap SPL/T22 to light-token |
| unwrap | [Action](typescript-client/actions/unwrap.ts) | [Instruction](typescript-client/instructions/unwrap.ts) | Unwrap light-token to SPL/T22 |
| approve | [Action](typescript-client/actions/delegate-approve.ts) | | Approve delegate |
| revoke | [Action](typescript-client/actions/delegate-revoke.ts) | | Revoke delegate |

### Rust

| | | | Description |
|---------|--------|-------------|-------------|
| create-mint | [Action](rust-client/actions/create_mint.rs) | [Instruction](rust-client/instructions/create_mint.rs) | Create a light-token mint with metadata |
| create-ata | [Action](rust-client/actions/create_ata.rs) | [Instruction](rust-client/instructions/create_ata.rs) | Create an associated light-token account |
| create-token-account | | [Instruction](rust-client/instructions/create_token_account.rs) | Create a light-token account with custom owner |
| mint-to | [Action](rust-client/actions/mint_to.rs) | [Instruction](rust-client/instructions/mint_to.rs) | Mint tokens to a light-account |
| mint-to-checked | | [Instruction](rust-client/instructions/mint_to_checked.rs) | Mint tokens with decimal validation |
| transfer-interface | [Action](rust-client/actions/transfer_interface.rs) | [Instruction](rust-client/instructions/transfer_interface.rs) | Transfer between light-token, T22, and SPL accounts |
| transfer-checked | [Action](rust-client/actions/transfer_checked.rs) | [Instruction](rust-client/instructions/transfer_checked.rs) | Transfer with decimal validation |
| spl-to-light-transfer | | [Instruction](rust-client/instructions/spl_to_light_transfer.rs) | Transfer from SPL to Light via TransferInterface |
| wrap | [Action](rust-client/actions/wrap.rs) | | Wrap SPL/T22 to light-token |
| unwrap | [Action](rust-client/actions/unwrap.rs) | | Unwrap light-token to SPL/T22 |
| burn | | [Instruction](rust-client/instructions/burn.rs) | Burn tokens |
| burn-checked | | [Instruction](rust-client/instructions/burn_checked.rs) | Burn tokens with decimal validation |
| approve | [Action](rust-client/actions/approve.rs) | [Instruction](rust-client/instructions/approve.rs) | Approve delegate |
| revoke | [Action](rust-client/actions/revoke.rs) | [Instruction](rust-client/instructions/revoke.rs) | Revoke delegate |
| freeze | | [Instruction](rust-client/instructions/freeze.rs) | Freeze a token account |
| thaw | | [Instruction](rust-client/instructions/thaw.rs) | Thaw a frozen token account |
| close | | [Instruction](rust-client/instructions/close.rs) | Close a token account |

## Program Examples

### Instructions

The instructions use pure CPI calls which you can combine with existing and / or light macros.
For existing programs, you can replace spl_token with light_token instructions as you need. The API is a superset of SPL-token so switching is straightforward.

| | Description |
|---------|-------------|
| [approve](programs/anchor/basic-instructions/approve/src/lib.rs) | Approve delegate via CPI |
| [burn](programs/anchor/basic-instructions/burn/src/lib.rs) | Burn tokens via CPI |
| [close](programs/anchor/basic-instructions/close/src/lib.rs) | Close token account via CPI |
| [create-associated-token-account](programs/anchor/basic-instructions/create-ata/src/lib.rs) | Create associated light-token account via CPI |
| [create-mint](programs/anchor/basic-instructions/create-mint/src/lib.rs) | Create light-token mint via CPI |
| [create-token-account](programs/anchor/basic-instructions/create-token-account/src/lib.rs) | Create light-token account via CPI |
| [freeze](programs/anchor/basic-instructions/freeze/src/lib.rs) | Freeze token account via CPI |
| [mint-to](programs/anchor/basic-instructions/mint-to/src/lib.rs) | Mint tokens via CPI |
| [revoke](programs/anchor/basic-instructions/revoke/src/lib.rs) | Revoke delegate via CPI |
| [thaw](programs/anchor/basic-instructions/thaw/src/lib.rs) | Thaw token account via CPI |
| [transfer-checked](programs/anchor/basic-instructions/transfer-checked/src/lib.rs) | Transfer with mint validation via CPI |
| [transfer-interface](programs/anchor/basic-instructions/transfer-interface/src/lib.rs) | Transfer between light-token, T22, and SPL accounts via CPI |

### Macros

| | Description |
|---------|-------------|
| [counter](programs/anchor/basic-macros/counter) | Create PDA with sponsored rent-exemption |
| [create-associated-token-account](programs/anchor/basic-macros/create-ata) | Create associated light-token account |
| [create-mint](programs/anchor/basic-macros/create-mint) | Create light-token mint |
| [create-token-account](programs/anchor/basic-macros/create-token-account) | Create light-token account |

### Examples

| | Description |
|---------|-------------|
| [create-and-transfer](programs/anchor/create-and-transfer) | Create account via macro and transfer via CPI |


## Documentation

Learn more [about Light-Token here](https://www.zkcompression.com/light-token/welcome).
Learn more [about Light-Token here](https://www.zkcompression.com/light-token/welcome).
44 changes: 44 additions & 0 deletions programs/anchor/Anchor.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[toolchain]

[features]
resolution = true
skip-lint = false

[workspace]
members = [
"basic-macros/counter",
"basic-macros/create-mint",
"basic-macros/create-ata",
"basic-macros/create-token-account",
"create-and-transfer",
"basic-instructions/approve",
"basic-instructions/burn",
"basic-instructions/close",
"basic-instructions/create-ata",
"basic-instructions/create-mint",
"basic-instructions/create-token-account",
"basic-instructions/freeze",
"basic-instructions/mint-to",
"basic-instructions/revoke",
"basic-instructions/thaw",
"basic-instructions/transfer-checked",
"basic-instructions/transfer-interface",
]

[programs.localnet]
escrow = "FKJs6rp6TXJtxzLiPtdYhqa9ExRuBXG2zwh4fda6WATN"
fundraiser = "Eoiuq1dXvHxh6dLx3wh9gj8kSAUpga11krTrbfF5XYsC"
light_token_minter = "3EPJBoxM8Evtv3Wk7R2mSWsrSzUD7WSKAaYugLgpCitV"
swap_example = "AsGVFxWqEn8icRBFQApxJe68x3r9zvfSbmiEzYFATGYn"
counter = "PDAm7XVHEkBvzBYDh8qF3z8NxnYQzPjGQJKcHVmMZpT"
create_and_transfer = "672fL1Nm191MbPoygNM9DRiG2psBELn97XUpGbU3jW7E"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "localnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
Loading
Loading