what-pinocchio-is
github repo: https://github.com/anza-xyz/pinocchio
helius blog: https://www.helius.dev/blog/pinocchio
practice blueshift_gg: introduction-to-pinocchio/pinocchio-101
1. What is Pinocchio?
Pinocchio is a zero-dependency framework for writing Solana programs in pure Rust. It avoids solana-program, doesn't rely on the standard library, and gives you full control over how your smart contract interacts with the Solana runtime.
2. Why skip solana-program
The solana-program crate adds helpful abstractions, but it also brings overhead: extra deserialization, hidden allocations, and increased binary size. For programs where compute efficiency or size matters, it's more than you need.
3. How Pinocchio works
Solana passes your program a raw byte array as input. Pinocchio uses this to define its own entrypoint, account types, and system calls — all without needing the Solana SDK. You parse exactly what you need, when you need it.
4. Entrypoint macro
Pinocchio includes an entrypoint!
macro that sets up your Solana program’s entrypoint with minimal boilerplate. It handles the program ID, accounts array, and instruction data — giving you a clean and direct starting point for logic.
5. Lazy entrypoint for more control
If you want to delay parsing and save compute units, Pinocchio provides lazy_program_entrypoint!
. This gives you manual control over when and how to parse accounts or instruction data. Useful for lean programs or conditional logic.
6. No allocator mode
You can enforce a no-allocation policy using the no_allocator!
macro. This ensures that any attempt to allocate memory in your program will fail at runtime. Helps you stay fully no_std
and avoid hidden costs.
7. When to use Pinocchio
Use Pinocchio when you're building low-level Solana programs, working with tight compute budgets, or want to keep your binaries small. It's also useful for protocols doing deep CPI or targeting MEV-aware, high-performance flows.
8. When not to use it
If you're prototyping, using Anchor for convenience, or don’t mind a bit of overhead, then Pinocchio might be overkill. It's a tool for precision — not for speed of development or general-purpose apps.
9. Conclusion
Pinocchio isn’t trying to replace Anchor or solana-program for everyone. It's for builders who care about what every byte and compute unit does. If you're optimizing for performance, safety, and clarity, Pinocchio gives you the raw tools to build on Solana — your way.