#account #token #instructions

pinocchio-associated-token-account

Pinocchio helpers to invoke Associated Token Account program instructions

2 releases

0.1.1 Mar 19, 2025
0.1.0 Jan 25, 2025

#137 in #account

Download history 90/week @ 2025-01-21 18/week @ 2025-01-28 13/week @ 2025-02-04 1/week @ 2025-02-11 19/week @ 2025-02-18 51/week @ 2025-02-25 46/week @ 2025-03-04 32/week @ 2025-03-11 198/week @ 2025-03-18 30/week @ 2025-03-25 38/week @ 2025-04-01

307 downloads per month

Apache-2.0

170KB
2K SLoC

pinocchio-associated-token-account

pinocchio-associated-token-account

Overview

This crate contains pinocchio helpers to perform cross-program invocations (CPIs) for SPL Associated Token Account program 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.

This is a no_std crate.

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

Getting Started

From your project folder:

cargo add pinocchio-associated-token-account

This will add the pinocchio-associated-token-account dependency to your Cargo.toml file.

Examples

Creating an associated token account:

// Those examples assume that each instruction receives writable and signer `funding_account` account,
// writable `account` account, and `wallet`, `mint`, `system_program`, `token_program` accounts.
Create {
    funding_account,
    account,
    wallet,
    mint,
    system_program,
    token_program,
}.invoke()?;

CreateIdempotent {
    funding_account,
    account,
    wallet,
    mint,
    system_program,
    token_program,
}.invoke()?;

Recovering Nested

// This example assumes that instruction receives writable and signer `wallet` account,
// writable `account` and `destination_account`, and `mint`, `owner_account`, `owner_mint`,
// `token_program` accounts.
RecoverNested {
    account,
    mint,
    destination_account,
    owner_account,
    owner_mint,
    wallet,
    token_program,
}.invoke()?;

License

The code is licensed under the Apache License Version 2.0

Dependencies