Overview
Pinocchio is a zero-dependency library to create Solana programs in Rust. It takes advantage of the way SBF loaders serialize the program input parameters into a byte array that is then passed to the program's entrypoint to define zero-copy types to read the input. Since the communication between a program and SBF loader — either at the first time the program is called or when one program invokes the instructions of another program — is done via a byte array, a program can define its own types. This completely eliminates the dependency on the solana-program crate, which in turn mitigates dependency issues by having a crate specifically designed to create on-chain programs.
Pinocchio can be used as a replacement for solana-program to write on-chain programs.
The library defines:
- program entrypoint
- core data types
- logging macros
syscallfunctions- access to system accounts (
sysvar) - cross-program invocation
Features
- Zero dependencies and
no_stdcrate - Efficient
entrypoint!macro – no copies or allocations - Improved CU consumption of cross-program invocations
Getting started
From your project folder:
On your entrypoint definition:
use ;
entrypoint!;
⚠️ Note: You should use the types from the
pinocchiocrate instead ofsolana-program. If you need to invoke a different program, you will need to redefine its instruction builder to create an equivalent instruction data usingpinocchiotypes.
License
The code is licensed under the Apache License Version 2.0
The library in this repository is based/includes code from: