7 releases (4 breaking)
Uses new Rust 2024
| 0.6.0 | Feb 27, 2026 |
|---|---|
| 0.3.1 | Feb 25, 2026 |
| 0.2.0 | Dec 13, 2025 |
| 0.1.2 | Nov 8, 2025 |
| 0.0.0 | Oct 7, 2025 |
#17 in #pinocchio
130KB
2K
SLoC
pina
Core runtime crate for building Solana programs on top of pinocchio.
It provides zero-copy account loaders, discriminator-aware account/instruction/event modeling, account validation traits, and no_std entrypoint helpers.
Installation
cargo add pina
Enable optional token helpers:
cargo add pina --features token
What This Crate Includes
nostd_entrypoint!forno_stdSolana entrypoint wiring.#[account],#[instruction],#[event],#[error],#[discriminator], and#[derive(Accounts)]integration via the defaultderivefeature.- Validation chains on
AccountView(assert_signer,assert_writable,assert_owner, PDA checks, sysvar checks, and more). - Zero-copy POD wrappers (
PodU*,PodI*,PodBool) for stable on-chain layouts. - CPI helpers for system/token operations.
Feature Flags
derive(default): enablespina_macrosre-exports.logs(default): enables Solana log macros viasolana-program-log.token: enables SPL token/token-2022 and ATA helpers.
Minimal Program Skeleton
#![no_std]
use pina::*;
declare_id!("YourProgramId11111111111111111111111111111111");
#[discriminator]
pub enum Instruction {
Initialize = 0,
}
#[instruction(discriminator = Instruction, variant = Initialize)]
pub struct InitializeInstruction {}
nostd_entrypoint!(process_instruction);
fn process_instruction(
program_id: &Address,
accounts: &[AccountView],
data: &[u8],
) -> ProgramResult {
let ix: Instruction = parse_instruction(program_id, &ID, data)?;
match ix {
Instruction::Initialize => {
let _ = InitializeInstruction::try_from_bytes(data)?;
let _ = accounts;
Ok(())
}
}
}
Related Crates
pina_macros: proc-macro implementations for the attributes and derives used here.pina_cli: CLI/library used to generate Codama IDLs from Pina programs.pina_sdk_ids: shared Solana program/sysvar IDs.
Codama IDLs
pina models are designed to be extracted into Codama IDLs through pina_cli.
pina idl --path ./my_program --output ./idls/my_program.json
From there you can generate JS clients with Codama renderers, or Pina-style Rust clients using this repository's pina_codama_renderer tool.
Dependencies
~0.7–2.7MB
~51K SLoC