3 releases (breaking)

0.2.0 Jan 6, 2026
0.1.0 Aug 27, 2025
0.0.0 Aug 6, 2025

#4 in #token-2022

Download history 324/week @ 2025-10-22 173/week @ 2025-10-29 151/week @ 2025-11-05 194/week @ 2025-11-12 362/week @ 2025-11-19 508/week @ 2025-11-26 419/week @ 2025-12-03 114/week @ 2025-12-10 160/week @ 2025-12-17 182/week @ 2025-12-24 155/week @ 2025-12-31 487/week @ 2026-01-07 444/week @ 2026-01-14 369/week @ 2026-01-21 481/week @ 2026-01-28 393/week @ 2026-02-04

1,717 downloads per month
Used in 2 crates

Apache-2.0

66KB
1K SLoC

pinocchio-token-2022

pinocchio-token-2022

Overview

This crate contains pinocchio helpers to perform cross-program invocations (CPIs) for SPL Token-2022 instructions.

Each instruction defines a struct with the accounts and parameters required. Once all values are set, you can call directly invoke or invoke_signed to perform the CPI.

Instruction that are common to both SPL Token and SPL Token-2022 programs expect the program address, so they can be used to invoke either token program.

This is a no_std crate.

Note: The API defined in this crate is subject to change.

Examples

Initializing a mint account:

// This example assumes that the instruction receives a writable `mint`
// account; `authority` is an `Address`.
// The SPL Token program is being invoked.
InitializeMint {
    mint,
    rent_sysvar,
    decimals: 9,
    mint_authority: authority,
    freeze_authority: Some(authority),
    token_program: Address::from_str_const("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")
}.invoke()?;

Performing a transfer of tokens:

// This example assumes that the instruction receives writable `from` and `to`
// accounts, and a signer `authority` account.
// The SPL Token-2022 is being invoked.
Transfer {
    from,
    to,
    authority,
    amount: 10,
    token_program: Address::from_str_const("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb")
}.invoke()?;

License

The code is licensed under the Apache License Version 2.0

Dependencies

~245KB