light_compressed_token_sdk/lib.rs
1//! # Light Compressed Token SDK
2//!
3//! Low-level SDK for compressed token operations on Light Protocol.
4//!
5//! This crate provides the core building blocks for working with compressed token accounts,
6//! including instruction builders for transfers, mints, and compress/decompress operations.
7//!
8//! ## Compressed Token Accounts
9//! - are on Solana mainnet.
10//! - are compressed accounts.
11//! - can hold Light Mint and SPL Mint tokens.
12//! - cost 5,000 lamports to create.
13//! - are well suited for airdrops and reward distribution.
14//!
15//! ## Difference to Light-Token:
16//! [light-token](https://github.com/Lightprotocol/light-protocol/tree/main/sdk-libs/token-sdk): Solana account that holds token balances of light-mints, SPL or Token 22 mints for most token use cases (launchpads, DeFi, payments). Mint and token accounts with sponsored rent-exemption.
17//! Compressed token: Compressed account storing token data. Rent-free, for storage and distribution. Prefer Light Token for other purposes. Used by Light Token under the hood for rent-free storage of inactive Light Tokens.
18//!
19//! ## Features
20//!
21//! - `v1` - Enable v1 compressed token support
22//! - `anchor` - Enable Anchor framework integration
23//!
24//! For full examples, see the [Compressed Token Examples](https://github.com/Lightprotocol/examples-zk-compression).
25//!
26//! ## Operations reference
27//!
28//! | Operation | GitHub example |
29//! |-----------|----------------|
30//! | Create mint | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/create-mint.ts) |
31//! | Mint to | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/mint-to.ts) |
32//! | Transfer | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/transfer.ts) |
33//! | Approve | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/approve.ts) |
34//! | Revoke | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/revoke.ts) |
35//! | Compress | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/compress.ts) |
36//! | Compress SPL account | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/compress-spl-account.ts) |
37//! | Decompress | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/decompress.ts) |
38//! | Merge token accounts | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/merge-token-accounts.ts) |
39//! | Create token pool | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/create-token-pool.ts) |
40//!
41//! ### Toolkit guides
42//!
43//! | Topic | GitHub example |
44//! |-------|----------------|
45//! | Airdrop | [example](https://github.com/Lightprotocol/examples-zk-compression/tree/main/example-token-distribution) |
46//! | Privy integration | [example](https://github.com/Lightprotocol/examples-zk-compression/tree/main/privy) |
47//!
48//! ## Modules
49//!
50//! - [`compressed_token`] - Core compressed token types and instruction builders
51//! - [`error`] - Error types for compressed token operations
52//! - [`utils`] - Utility functions and default account configurations
53//! - [`constants`] - Program IDs and other constants
54//! - [`spl_interface`] - SPL interface PDA derivation utilities
55
56pub mod compat;
57pub mod compressed_token;
58pub mod constants;
59pub mod error;
60pub mod spl_interface;
61pub mod utils;
62
63// Conditional anchor re-exports
64#[cfg(feature = "anchor")]
65use anchor_lang::{AnchorDeserialize, AnchorSerialize};
66#[cfg(not(feature = "anchor"))]
67use borsh::{BorshDeserialize as AnchorDeserialize, BorshSerialize as AnchorSerialize};
68pub use light_compressed_account::instruction_data::compressed_proof::{
69 CompressedProof, ValidityProof,
70};