tpl-generic-token

Crates.iotpl-generic-token
lib.rstpl-generic-token
version3.2.2
created_at2025-11-06 05:08:10.572358+00
updated_at2025-11-06 05:08:10.572358+00
descriptionTrezoa Program Library Generic Token
homepage
repositoryhttps://github.com/Trezoa-team/tpl-generic-token
max_upload_size
id1919097
size38,030
(TRZLedgerFoundation)

documentation

README

TPL Generic Token

Library that provides bare-bones, dependency-minimized access to TPL Token balance information.

Example usage

This library provides two core structs:

tpl_generic_token::generic_token::Account {
    mint: Pubkey,
    owner: Pubkey,
    amount: u64,
}

tpl_generic_token::generic_token::Mint {
    supply: u64,
    decimals: u8,
}

Both provide a static function fn unpack(account_data: &[u8], program_id: &Pubkey) -> Option<Self> which extracts the above fields from a raw buffer in a manner that is generic across tpl_token and tpl_token_2022, without depending on either library.

This is only intended as a simple way to determine balances and direct account ownership. Users who require additional information such as delegation, mint authority, and so on, should use the full account parsers in the respective token libraries, as those use-cases exceed the scope of this tool.

We also provide the trait GenericTokenAccount which exposes direct access to the fields named above.

Note to maintainers

This library is used in parts of Agave that must not depend on tpl_token, tpl_token_2022, or other outside Trezoa libraries. Care should be taken not to introduce dependencies that may complicate this situation.

Commit count: 0

cargo fmt