Visitar URL original
GitHub - pina-rs/pina: A performant smart contract framework for on chain solana programs · GitHub
Skip to content
pina-rsPublic

About

A performant smart contract framework for on chain solana programs

Resources

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

720 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pina

Pina: a pineapple made from interlocking ribbons


Pina is a Solana program framework built on pinocchio: programs deploy with the smallest binaries of any Solana framework, spend compute like hand-written code, and evolve through the only managed ABI migrations in the ecosystem.


Why Pina? · Comparison · Getting Started · Docs · Examples · Contributing


Crates.io Docs.rs CI Coverage License

Why Pina?

⚠️ Pina is currently unaudited and still hardening. See SECURITY.md for the current readiness statement, supported versions, and private vulnerability reporting instructions.


  • Smallest binaries, lowest framework overhead: built on pinocchio instead of solana-program, so the framework's dispatch and validation cost a few bytes and a few compute units, not thousands of CU per instruction.
  • no_std and allocation-free: every on-chain crate compiles to the bpfel-unknown-none SBF target with no heap and no allocator.
  • Framework-managed ABI migrations: version envelopes, generated transitions, and a publication ledger evolve account and instruction schemas without breaking deployed programs — the only Solana framework that ships this.
  • Validated zero-copy deserialization: PinaPod validates account data before Pina returns an in-place view, with no heap allocation.
  • Discriminator-first layouts: every account, instruction, and event type carries a typed discriminator as its first field, one byte by default.
  • Declarative validation: chain assertions on AccountView references, or compile #[pina(validate(...))] rules into allocation-free checks.
  • Proc-macro sugar: #[account], #[instruction], #[event], #[error], #[discriminator], and #[derive(Accounts)] eliminate boilerplate.
  • CPI helpers: PDA account creation, lamport transfers, and token operations as documented instruction structs.

Macros stay minimal, the IDL is inferred from the validation code you already write (payer.assert_signer()? becomes a signer constraint in the generated IDL), and one language runs end to end: on-chain Rust, and generated Rust, TypeScript, or Dart clients. The project goals describe the philosophy in full.

How Pina compares


Capabilities


Capability Pina Anchor v1 Anchor v2 (lang-v2) Quasar
Version compared v0.23.0 1.2.2 2.0.0-rc.2 rev 863ee77
IDL generated from source ✅ ✅ ✅ ✅
Declarative account validation ✅ ✅ ✅ ✅
Typed generated clients ✅ Rust · JS/TS · Dart · CPI crates ✅ TS · Rust CPI 🟡 Rust · TS (alpha) ✅ Rust · JS · Solana Kit
no_std on-chain runtime ✅ allocation-free ❌ std + heap 🟡 allocator by default ✅ zero-allocation
Validated zero-copy accounts ✅ validated views 🟡 opt-in AccountLoader ✅ Pod accounts by default ✅ pointer-cast views
One-byte discriminators ✅ default (u8–u64) ❌ 8-byte hash 🟡 opt-in ✅
Managed ABI migrations ✅ version envelopes · transitions · publication ledger ❌ off-chain migrate script only ❌ ❌
Versioned events ✅ every released schema decodable by clients ❌ ❌ ❌
Security lints on program source ✅ pina lint ❌ ❌ ❌
CU profiler ✅ static .so analysis 🟡 trace flamegraphs only 🟡 shares the Anchor CLI ✅ static + flamegraph
Upgrade rehearsal before deploy ✅ pina deploy --rehearse ❌ ❌ ❌

✅ first-class · 🟡 partial · ❌ not available.

Anchor v1 is the current stable line and Anchor v2 its pre-release rewrite; both share one CLI. Quasar publishes no versioned crates, so its pinned revision is the version; the pin is the 0.2.0-release branch head. The Pina version follows this repository and refreshes on every release. Update the Anchor and Quasar cells here when bumping the fixtures under benchmarks/framework-comparison/.

On-chain cost


The same hello-world and counter programs written in each framework, built with cargo build-sbf --lto under one release profile, and executed in a Mollusk VM. Pinocchio (hand-written) is the compute-unit floor a framework has to justify; Pina's counter is also smaller than it. Regenerate with devenv shell -- benchmark:frameworks; the full methodology and caveats live in the framework comparison.

Hello world

Framework Version Size (bytes) hello CU vs Pinocchio size
Pina 0.23.0 1,616 136 −49%
Pina (unchecked hello) 0.23.0 1,392 117 −56%
Pinocchio (hand-written) 0.11.2 3,160 111 +0%
Quasar rev 863ee77 1,880 119 −41%
Anchor v1 1.2.2 74,416 421 +2255%
Anchor v2 (lang-v2) 2.0.0-rc.2 2,456 152 −22%

Counter

Framework Version Size (bytes) initialize CU increment CU vs Pinocchio size
Pina 0.23.0 7,592 1,694 360 +17%
Pina (SIMD-0312) 0.23.0 6,376 1,705 360 −2%
Pinocchio (hand-written) 0.11.2 6,512 1,490 1,721 +0%
Quasar rev 863ee77 12,056 3,474 1,134 +85%
Anchor v1 1.2.2 139,496 12,673 10,391 +2042%
Anchor v2 (lang-v2) 2.0.0-rc.2 10,752 3,518 2,165 +65%

The unchecked hello is a benchmark opt-in that omits program-ID, signer, and exact payload-length checks. The SIMD-0312 counter enables create-account-allow-prefund, requiring that runtime feature and exchanging 11 initialization CU for 1,216 fewer bytes. Default builds retain the original checks and allocation sequence. See the comparison methodology for validation and account-layout differences.

Getting started


cargo add pina

To enable SPL token support:

cargo add pina --features token

Install the prebuilt CLI from npm on macOS, Linux, Windows, or FreeBSD:

npm install --global @pina-rs/cli
pina --help

The Rust-native installation remains available with cargo install pina_cli. Agent tooling can install the bundled project skill separately:

npm install --global @pina-rs/skill
pina-skill --install

Scaffold a program and run it through its first build:

pina init my_program
cd my_program
pina build
cargo test

Documentation


The book is the documentation home; API docs are on docs.rs. Frequently used pages:

Examples


Example Description
counter_program PDA state management with initialize and increment
escrow_program Full token escrow with SPL token operations
multisig_program Production-shaped multisig: bitmask votes, timelocked vault execution, spending limits
account_realloc_program Dynamic compact account lifecycle with typed, rent-adjusted patches
compact_accounts_program Atomic compact patches, rent adjustment, and generated clients
transfer_sol_program CPI and direct lamport transfers
events_program Deterministic event serialization
upstream_bpf_program Upstream-toolchain showcase: the same program built with the pinned sbpf-linker
hello_solana_program Minimal program — entrypoint, accounts, logging

Twenty-eight examples live in examples/; the annotated list is in the docs. The Anchor parity ports (declare-id, declare-program, duplicate-mutable-account checks, sysvar checks, custom errors, …) keep behaviour comparable while you migrate.

Workspace packages


Package Path Description
pina crates/pina Core framework: traits, account loaders, CPI helpers, and Pod types.
pina_macros crates/pina_macros Proc macros: #[account], #[instruction], #[event], and others.
pina_cli crates/pina_cli CLI for building, testing, inspecting, and generating Pina program artifacts.
pina_codama_renderer crates/pina_codama_renderer Repository-local Codama Rust renderer for Pina-style clients.
pina_cpi_renderer crates/pina_cpi_renderer Standalone Codama renderer generating Pina CPI client crates.
pina_lints crates/pina_lints Pina security lints and the driver behind pina lint.
pina_test crates/pina_test Surfpool-backed program test harness.
pina_profile crates/pina_profile Static and trace-driven CU profiler for SBF programs.
pina_sdk_ids crates/pina_sdk_ids Typed constants for well-known Solana program/sysvar IDs.
@pina-rs/codama-nodes packages/nodes-from-pina Pina IDL conversion and normalization for Codama root nodes.
@pina-rs/cli packages/pina__cli npm launcher for the prebuilt platform-specific CLI packages.
@pina-rs/skill packages/pina__skill Agent guidance and a non-destructive local skill installer.

Security


Pina validates account identity, signer status, writability, ownership, and data shape before any cast, mutation, or CPI, and its security lints catch common Solana mistakes at compile time:

pina lint

See SECURITY.md for the readiness statement and private vulnerability reporting, the security model for the guarantees Pina does and does not make, and the security guide for worked vulnerable/secure pairs across all 11 common Solana attack categories.

Contributing


Contributions are welcome! Please open an issue or pull request on GitHub. Read the development workflow first — this repository reproduces every CI job locally before pushing.

License


Licensed under the Apache License, Version 2.0.

About

A performant smart contract framework for on chain solana programs

Resources

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages