Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Crates and Features

CratePathDescription
pinacrates/pinaCore framework — traits, account loaders, CPI helpers, Pod types.
pina_macroscrates/pina_macrosProc macros — #[account], #[instruction], #[event], etc.
pina_clicrates/pina_cliCLI/library for IDL generation, Codama integration, scaffolding.
pina_codama_renderercrates/pina_codama_rendererRepository-local Codama Rust renderer for Pina-style clients.
pina_pod_primitivescrates/pina_pod_primitivesAlignment-safe no_std POD primitive wrappers.
pina_profilecrates/pina_profileStatic CU profiler for compiled SBF programs.
pina_sdk_idscrates/pina_sdk_idsTyped constants for well-known Solana program/sysvar IDs.

crates/pina

Core runtime crate for on-chain program logic.

Includes:

  • AccountView and 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:

FeatureDefaultDescription
deriveYesEnables proc macros (#[account], #[instruction], etc.)
logsYesEnables on-chain logging via solana-program-log
tokenNoEnables SPL token / token-2022 helpers and ATA utilities

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:

CommandDescription
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 generateGenerate 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 conversion macro helpers shared by pina and generated clients.

Arithmetic operators (+, -, *) 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.

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 helpers
  • instructions.rs — instruction page, account metas
  • types.rs — Pod type rendering, defined types
  • errors.rs — error page rendering
  • discriminator.rs — discriminator rendering
  • seeds.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.