light_token/lib.rs
1//! # Light Token SDK
2//!
3//! The base library to use Light Token Accounts, Light Mints, and compressed token accounts.
4//!
5//! ## Light Token Accounts
6//! - are on Solana devnet.
7//! - are Solana accounts.
8//! - can hold Light Mint and SPL Mint tokens.
9//! - cost 17,288 lamports to create with 24 hours rent.
10//! - are rentfree:
11//! - rent exemption is sponsored by the protocol.
12//! - rent is 388 lamports per rent epoch (1.5 hours).
13//! - once the account's lamports balance is insufficient, it is compressed to a compressed token account.
14//! - compressed tokens can be decompressed to a Light Token account.
15//! - configurable lamports per write (eg transfer) keep the Light Token account perpetually funded when used. So you don't have to worry about funding rent.
16//!
17//! ## Compressed Token Accounts
18//! - are on Solana mainnet.
19//! - are compressed accounts.
20//! - can hold Light Mint and SPL Mint tokens.
21//! - cost 5,000 lamports to create.
22//! - are well suited for airdrops and reward distribution.
23//!
24//! ## Light Mints
25//! - are on Solana devnet.
26//! - are Compressed accounts.
27//! - cost 15,000 lamports to create.
28//! - support `TokenMetadata`.
29//!
30//!
31//! For full program examples, see the [Light Token Examples](https://github.com/Lightprotocol/examples-light-token).
32//! For detailed documentation, visit [zkcompression.com](https://www.zkcompression.com/).
33//! For rust client development see [`light-client`](https://docs.rs/light-client).
34//! For rust program testing see [`light-program-test`](https://docs.rs/light-program-test).
35//! For local test validator with light system programs see [Light CLI](https://www.npmjs.com/package/@lightprotocol/zk-compression-cli).
36//!
37//!
38//!
39//! ## Features
40//!
41//! 1. anchor - Derives AnchorSerialize, AnchorDeserialize instead of BorshSerialize, BorshDeserialize.
42//! 2. compressible - utility functions for compressible sdk macros.
43//!
44//! ## Common Operations
45//!
46//! | Operation | Instruction Builder | CPI Builder |
47//! |-----------|----------------|-------------|
48//! | Create Associated Token Account | [`CreateAssociatedTokenAccount`](instruction::CreateAssociatedTokenAccount) | [`CreateAssociatedAccountCpi`](instruction::CreateAssociatedAccountCpi) |
49//! | Create Token Account | [`CreateTokenAccount`](instruction::CreateTokenAccount) | [`CreateTokenAccountCpi`](instruction::CreateTokenAccountCpi) |
50//! | Transfer | [`Transfer`](instruction::Transfer) | [`TransferCpi`](instruction::TransferCpi) |
51//! | Transfer Interface (auto-detect) | [`TransferInterface`](instruction::TransferInterface) | [`TransferInterfaceCpi`](instruction::TransferInterfaceCpi) |
52//! | Close Token account | [`CloseAccount`](instruction::CloseAccount) | [`CloseAccountCpi`](instruction::CloseAccountCpi) |
53//! | Create Mint | [`CreateMint`](instruction::CreateMint) | [`CreateMintCpi`](instruction::CreateMintCpi) |
54//! | MintTo | [`MintTo`](instruction::MintTo) | [`MintToCpi`](instruction::MintToCpi) |
55//!
56//!
57//! # Disclaimer
58//! This library is not audited and in a beta state. Use at your own risk and expect breaking changes.
59
60#[cfg(feature = "anchor")]
61pub mod anchor;
62pub mod compressed_token;
63pub mod compressible;
64pub mod instruction;
65
66pub mod constants;
67pub mod error;
68pub mod pack;
69pub mod spl_interface;
70pub mod utils;
71
72// Conditional anchor re-exports
73#[cfg(feature = "anchor")]
74use anchor_lang::{AnchorDeserialize, AnchorSerialize};
75#[cfg(not(feature = "anchor"))]
76use borsh::{BorshDeserialize as AnchorDeserialize, BorshSerialize as AnchorSerialize};
77pub use light_compressed_account::instruction_data::compressed_proof::{
78 CompressedProof, ValidityProof,
79};
80pub use light_token_interface::{
81 instructions::extensions::{ExtensionInstructionData, TokenMetadataInstructionData},
82 state::AdditionalMetadata,
83};
84pub use pack::compat;