Skip to main content

light_token/
lib.rs

1//! # Light Token SDK
2//!
3//! The base library to use Light Token Accounts, and Light Mints.
4//!
5//! ## Light Token Accounts
6//! - are on Solana devnet.
7//! - are Solana accounts.
8//! - are functionally equivalent to SPL token accounts.
9//! - can hold tokens of Light, SPL and Token 2022 mints.
10//! - cost 17,288 lamports to create with 24 hours rent.
11//! - are rentfree:
12//!     - rent exemption is sponsored by the token program.
13//!     - rent is 388 lamports per rent epoch (1.5 hours).
14//!     - once the account's lamports balance is insufficient, it is auto-compressed to a compressed token account.
15//!     - the accounts state is cryptographically preserved on the Solana ledger.
16//!     - compressed tokens can be loaded to a Light Token account.
17//!     - 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.
18//!     - users load a compressed account into a light account in-flight when using the account again.
19//!
20//! ## Light Mints
21//! - are on Solana devnet.
22//! - are Compressed accounts.
23//! - support `TokenMetadata`.
24//! - have the same rent-config as light token accounts
25//!
26//!
27//! For full program examples, see the [Light Token Examples](https://github.com/Lightprotocol/examples-light-token).
28//!
29//! | Operation | Docs guide | GitHub example |
30//! |-----------|-----------|----------------|
31//! | `CreateAssociatedAccountCpi` | [create-ata](https://zkcompression.com/light-token/cookbook/create-ata) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/create-ata) |
32//! | `CreateTokenAccountCpi` | [create-token-account](https://zkcompression.com/light-token/cookbook/create-token-account) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/create-token-account) |
33//! | `CreateMintCpi` | [create-mint](https://zkcompression.com/light-token/cookbook/create-mint) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/create-mint) |
34//! | `MintToCpi` | [mint-to](https://zkcompression.com/light-token/cookbook/mint-to) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/mint-to) |
35//! | `MintToCheckedCpi` | [mint-to](https://zkcompression.com/light-token/cookbook/mint-to) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/mint-to-checked) |
36//! | `BurnCpi` | [burn](https://zkcompression.com/light-token/cookbook/burn) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/burn) |
37//! | `TransferCheckedCpi` | [transfer-checked](https://zkcompression.com/light-token/cookbook/transfer-checked) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/transfer-checked) |
38//! | `TransferInterfaceCpi` | [transfer-interface](https://zkcompression.com/light-token/cookbook/transfer-interface) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/transfer-interface) |
39//! | `ApproveCpi` | [approve-revoke](https://zkcompression.com/light-token/cookbook/approve-revoke) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/approve) |
40//! | `RevokeCpi` | [approve-revoke](https://zkcompression.com/light-token/cookbook/approve-revoke) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/revoke) |
41//! | `FreezeCpi` | [freeze-thaw](https://zkcompression.com/light-token/cookbook/freeze-thaw) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/freeze) |
42//! | `ThawCpi` | [freeze-thaw](https://zkcompression.com/light-token/cookbook/freeze-thaw) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/thaw) |
43//! | `CloseAccountCpi` | [close-token-account](https://zkcompression.com/light-token/cookbook/close-token-account) | [example](https://github.com/Lightprotocol/examples-light-token/tree/main/program-examples/anchor/basic-instructions/close-token-account) |
44//!
45//! ## Features
46//!
47//! 1. anchor - Derives AnchorSerialize, AnchorDeserialize instead of BorshSerialize, BorshDeserialize.
48//! 2. compressible - utility functions for compressible sdk macros.
49//!
50//! ## Common Operations
51//!
52//! | Operation | Instruction Builder | CPI Builder |
53//! |-----------|----------------|-------------|
54//! | Create Associated Token Account | [`CreateAssociatedTokenAccount`](instruction::CreateAssociatedTokenAccount) | [`CreateAssociatedAccountCpi`](instruction::CreateAssociatedAccountCpi) |
55//! | Create Token Account | [`CreateTokenAccount`](instruction::CreateTokenAccount) | [`CreateTokenAccountCpi`](instruction::CreateTokenAccountCpi) |
56//! | Transfer | [`Transfer`](instruction::Transfer) | [`TransferCpi`](instruction::TransferCpi) |
57//! | Transfer Interface (auto-detect) | [`TransferInterface`](instruction::TransferInterface) | [`TransferInterfaceCpi`](instruction::TransferInterfaceCpi) |
58//! | Close Token account | [`CloseAccount`](instruction::CloseAccount) | [`CloseAccountCpi`](instruction::CloseAccountCpi) |
59//! | Create Mint | [`CreateMint`](instruction::CreateMint) | [`CreateMintCpi`](instruction::CreateMintCpi) |
60//! | MintTo | [`MintTo`](instruction::MintTo) | [`MintToCpi`](instruction::MintToCpi) |
61//!
62//!
63//! # Disclaimer
64//! This library is not audited and in a beta state. Use at your own risk and expect breaking changes.
65
66pub mod constants;
67pub mod error;
68pub mod instruction;
69pub mod spl_interface;
70pub mod utils;
71
72// Re-export key constants and functions from constants module
73pub use constants::{
74    config_pda, cpi_authority, id, LIGHT_TOKEN_CPI_AUTHORITY, LIGHT_TOKEN_PROGRAM_ID,
75};
76pub use light_compressed_account::instruction_data::compressed_proof::{
77    CompressedProof, ValidityProof,
78};
79pub use light_compressed_token_sdk::compat;
80pub use light_token_interface::{
81    instructions::extensions::{ExtensionInstructionData, TokenMetadataInstructionData},
82    state::AdditionalMetadata,
83};