Skip to main content

Crate light_token

Crate light_token 

Source
Expand description

§Light Token SDK

The base library to use Light Token Accounts, and Light Mints.

§Light Token Accounts

  • are on Solana devnet.
  • are Solana accounts.
  • are functionally equivalent to SPL token accounts.
  • can hold tokens of Light, SPL and Token 2022 mints.
  • cost 17,288 lamports to create with 24 hours rent.
  • are rentfree:
    • rent exemption is sponsored by the token program.
    • rent is 388 lamports per rent epoch (1.5 hours).
    • once the account’s lamports balance is insufficient, it is auto-compressed to a compressed token account.
    • the accounts state is cryptographically preserved on the Solana ledger.
    • compressed tokens can be loaded to a Light Token account.
    • 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.
    • users load a compressed account into a light account in-flight when using the account again.

§Light Mints

  • are on Solana devnet.
  • are Compressed accounts.
  • support TokenMetadata.
  • have the same rent-config as light token accounts

For full program examples, see the Light Token Examples.

OperationDocs guideGitHub example
CreateAssociatedAccountCpicreate-ataexample
CreateTokenAccountCpicreate-token-accountexample
CreateMintCpicreate-mintexample
MintToCpimint-toexample
MintToCheckedCpimint-toexample
BurnCpiburnexample
TransferCheckedCpitransfer-checkedexample
TransferInterfaceCpitransfer-interfaceexample
ApproveCpiapprove-revokeexample
RevokeCpiapprove-revokeexample
FreezeCpifreeze-thawexample
ThawCpifreeze-thawexample
CloseAccountCpiclose-token-accountexample

§Features

  1. anchor - Derives AnchorSerialize, AnchorDeserialize instead of BorshSerialize, BorshDeserialize.
  2. compressible - utility functions for compressible sdk macros.

§Common Operations

OperationInstruction BuilderCPI Builder
Create Associated Token AccountCreateAssociatedTokenAccountCreateAssociatedAccountCpi
Create Token AccountCreateTokenAccountCreateTokenAccountCpi
TransferTransferTransferCpi
Transfer Interface (auto-detect)TransferInterfaceTransferInterfaceCpi
Close Token accountCloseAccountCloseAccountCpi
Create MintCreateMintCreateMintCpi
MintToMintToMintToCpi

§Disclaimer

This library is not audited and in a beta state. Use at your own risk and expect breaking changes.

Re-exports§

pub use constants::config_pda;
pub use constants::cpi_authority;
pub use constants::id;
pub use constants::LIGHT_TOKEN_CPI_AUTHORITY;

Modules§

compat
Solana-compatible token types using solana_pubkey::Pubkey.
constants
Constants for Light Token SDK.
error
Error types for light-token SDK.
instruction
High-level builders for Light Token operations.
spl_interface
SPL interface PDA derivation utilities.
utils
Utility functions and default account configurations.

Structs§

AdditionalMetadata
CompressedProof
TokenMetadataInstructionData
ValidityProof

Enums§

ExtensionInstructionData

Constants§

LIGHT_TOKEN_PROGRAM_ID