#instructions #pinocchio #account #sol #byte

pinocchio-system

Pinocchio helpers to invoke System program instructions

8 releases

0.2.3 Mar 29, 2025
0.2.2 Mar 19, 2025
0.2.1 Jan 3, 2025
0.2.0 Oct 26, 2024
0.0.0 Oct 2, 2024

#1171 in Cryptography

Download history 47/week @ 2025-01-22 38/week @ 2025-01-29 87/week @ 2025-02-05 84/week @ 2025-02-12 102/week @ 2025-02-19 180/week @ 2025-02-26 149/week @ 2025-03-05 160/week @ 2025-03-12 289/week @ 2025-03-19 891/week @ 2025-03-26 370/week @ 2025-04-02 653/week @ 2025-04-09 647/week @ 2025-04-16 469/week @ 2025-04-23 525/week @ 2025-04-30 632/week @ 2025-05-07

2,346 downloads per month
Used in 7 crates (3 directly)

Apache-2.0

195KB
2.5K SLoC

pinocchio-system

pinocchio-system

Overview

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

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