pinocchio-toolkit
Zero-boilerplate helpers for Pinocchio Solana programs
Installation
Add to your Cargo.toml:
[]
= "0.1.0"
= "0.9"
= "0.3"
Usage
Create a PDA Account
use AccountInfo;
use create_pda_account;
// In your instruction handler:
What it does for you
Without pinocchio-toolkit:
// 30+ lines of boilerplate:
// - Get rent sysvar
// - Build seed arrays with MaybeUninit
// - Construct CreateAccount instruction
// - Convert seeds to Seed types with unsafe
// - Call invoke_signed with correct types
With pinocchio-toolkit:
// One line:
?;
Reference
create_pda_account<const N: usize>
Create a rent-exempt PDA account owned by your program.
Arguments:
payer: &AccountInfo– The account paying for rent (must be signer)pda: &AccountInfo– The uninitialized PDA accountprogram_id: &Pubkey– Your program IDspace: u64– How many bytes you want (e.g.core::mem::size_of::<MyData>())seeds: &[&[u8]]– PDA seeds WITHOUT the bumpbump: u8– The PDA bump seed
Const Generic:
N: usize– Maximum number of seed slices (must be >=seeds.len())
Returns:
Ok(())on successErr(ProgramError)on failure
Errors:
MissingRequiredSignature- Payer is not a signerAccountAlreadyInitialized- PDA already has lamportsInvalidSeeds- PDA derivation doesn't matchInvalidArgument- Too many seeds for array sizeN
Examples
Real Working Program
See tests/test-program.rs for a complete example Solana program that uses pinocchio-toolkit:
use ;
entrypoint!;
This real program:
- ✅ Compiles with
cargo build-sbf - ✅ Deploys to Solana (via litesvm)
- ✅ Creates PDAs with only 1,930 compute units
- ✅ Handles rent, validation, and CPI automatically
Integration Tests
See tests/integration_test.rs for the full test suite using litesvm.
Run the tests:
# Build the test program
&& &&
# Run integration tests
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.