Crates and Features
| Crate | Path | Description |
|---|---|---|
pina | crates/pina | Core framework — traits, account loaders, CPI helpers, Pod types. |
pina_macros | crates/pina_macros | Proc macros — #[account], #[instruction], #[event], etc. |
pina_cli | crates/pina_cli | CLI/library for IDL generation, Codama integration, scaffolding. |
pina_codama_renderer | crates/pina_codama_renderer | Repository-local Codama Rust renderer for Pina-style clients. |
pina_pod_primitives | crates/pina_pod_primitives | no_std POD primitives — integer/bool wrappers, fixed-capacity collections. |
pina_profile | crates/pina_profile | Static CU profiler for compiled SBF programs. |
pina_sdk_ids | crates/pina_sdk_ids | Typed constants for well-known Solana program/sysvar IDs. |
crates/pina
Core runtime crate for on-chain program logic.
Includes:
AccountViewand validation chain helpers.- Typed account loaders and discriminator checks.
- CPI/system/token helper utilities.
nostd_entrypoint!and instruction parsing helpers.- Instruction introspection (flash loan guards, sandwich detection).
- Pod types with full arithmetic operator support.
Feature flags:
| Feature | Default | Description |
|---|---|---|
derive | Yes | Enables proc macros (#[account], #[instruction], etc.) |
logs | Yes | Enables on-chain logging via solana-program-log |
token | No | Enables SPL token / token-2022 helpers and ATA utilities |
memo | No | Enables memo program helpers via pina::memo |
account-resize | No | Enables account realloc helpers that call Pinocchio resize APIs |
Feature selection tips
deriveis the normal choice for program crates; disable it only when you want the low-level runtime traits without the proc macros.logsis useful during initial development and debugging, testing, and audits. Disable it when you want the smallest possible binary or completely silent runtime failures.tokenenablespina::token,pina::token_2022,pina::associated_token_account, and theTokenAccountcompatibility aliases over the upstream renamed account types.memois separate fromtoken, so memo CPI support can be enabled without pulling in the token helper surface.account-resizeonly unlocks realloc helpers such asrealloc_account()andrealloc_account_zero(). Close helpers still do not implicitly resize or zero account data.
See ADR 0004 and ADR 0005 for the architectural rationale behind these feature and runtime boundaries. For concrete token CPI patterns, see Token CPI Recipes.
crates/pina_macros
Proc-macro crate used by pina.
Provides:
#[discriminator]#[account]#[instruction]#[event]#[error]#[derive(Accounts)]
crates/pina_cli
Developer CLI and library.
Commands:
| Command | Description |
|---|---|
pina init <name> | Scaffold a new Pina program project |
pina idl --path <dir> | Generate a Codama IDL JSON from a Pina program |
pina profile <path.so> | Static CU profiler for compiled SBF binaries |
pina codama generate | Generate Codama IDLs and Rust/JS clients for examples |
The IDL parser supports multi-file programs — it follows mod declarations from src/lib.rs to discover accounts, instructions, and discriminators across all source files.
Library surface:
pina_cli::generate_idl(program_path, name_override)pina_cli::init_project(path, package_name, force)
crates/pina_pod_primitives
no_std crate containing alignment-safe POD primitive wrappers (PodBool, PodU*, PodI*) and fixed-capacity collection types (PodOption, PodString, PodVec) shared by pina and generated clients.
Arithmetic operators (+, -, *) on Pod integer types use wrapping semantics in release builds for CU efficiency and panic on overflow in debug builds. Use checked_add, checked_sub, checked_mul, checked_div where overflow must be detected in all build profiles.
Each Pod integer type provides ZERO, MIN, and MAX constants.
| Type | Purpose | Layout |
|---|---|---|
PodOption<T: Pod> | Fixed-size Option<T> | 1-byte discriminant + T |
PodString<N, PFX=1> | Fixed-capacity string | PFX-byte length prefix + N data bytes |
PodVec<T: Pod, N, PFX=2> | Fixed-capacity vec | PFX-byte length prefix + N elements |
All collection types are #[repr(C)], alignment-1, and implement bytemuck::Pod + bytemuck::Zeroable. Length prefixes (PFX) default to 1 byte for strings (max 255) and 2 bytes for vectors (max 65 535 elements).
Collection types store data inline with a length prefix, enabling zero-copy access inside #[repr(C)] account structs. Overflow is detected at insertion time — try_set / try_push return Err(PodCollectionError::Overflow) when capacity is exceeded.
PodString provides UTF-8 validation via try_as_str(), while PodVec offers slice-based access via as_slice() / as_mut_slice(). PodOption mirrors the Option<T> API with get(), set(), and clear().
crates/pina_profile
The pina profile command analyzes compiled SBF .so binaries to estimate per-function compute unit costs without requiring a running validator.
pina profile target/deploy/my_program.so # text summary
pina profile target/deploy/my_program.so --json # JSON for CI
pina profile target/deploy/my_program.so -o r.json # write to file
The profiler decodes each SBF instruction opcode and assigns costs: regular instructions cost 1 CU, syscalls cost 100 CU.
crates/pina_codama_renderer
Repository-local renderer that generates Pina-style Rust client code from Codama JSON IDLs. The renderer is organized into focused modules under src/render/:
accounts.rs— account page and PDA helpersinstructions.rs— instruction page, account metastypes.rs— Pod type rendering, defined typeserrors.rs— error page renderingdiscriminator.rs— discriminator renderingseeds.rs— seed parameter/constant rendering
Use this when you want generated Rust models to match Pina’s fixed-size discriminator-first/bytemuck conventions.
crates/pina_sdk_ids
no_std crate that exports well-known Solana program/sysvar IDs as typed constants.
Use this crate to avoid hardcoded base58 literals in validation logic.