#account #instructions #solana #cpi #invoke #helper #programs

pinocchio-system

Pinocchio helpers to invoke System program instructions

6 releases

0.2.1 Jan 3, 2025
0.2.0 Oct 26, 2024
0.1.3 Oct 16, 2024
0.0.0 Oct 2, 2024

#9 in #cpi

Download history 140/week @ 2024-10-22 86/week @ 2024-10-29 155/week @ 2024-11-05 60/week @ 2024-11-12 70/week @ 2024-11-19 42/week @ 2024-11-26 45/week @ 2024-12-03 51/week @ 2024-12-10 52/week @ 2024-12-17 18/week @ 2024-12-24 172/week @ 2024-12-31 76/week @ 2025-01-07 139/week @ 2025-01-14 50/week @ 2025-01-21 36/week @ 2025-01-28 78/week @ 2025-02-04

314 downloads per month

Apache-2.0

155KB
2K SLoC

pinocchio-system

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

Each instruction defines an 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.

Examples

Creating a new account:

// This example assumes that the instruction receives a writable signer `payer_info`
// and `new_account_info` accounts.
CreateAccount {
    from: payer_info,
    to: new_account_info,
    lamports: 1_000_000_000, // 1 SOL
    space: 200,              // 200 bytes
    owner: &spl_token::ID,
}.invoke()?;

Performing a transfer of lamports:

// This example assumes that the instruction receives a writable signer `payer_info`
// account and a writable `recipient_info` account.
Transfer {
    from: payer_info,
    to: recipient_info,
    lamports: 500_000_000, // 0.5 SOL
}.invoke()?;

License

The code is licensed under the Apache License Version 2.0

Dependencies