Skip to content

Create Solana programs with no dependencies attached

License

Notifications You must be signed in to change notification settings

igneous-labs/pinocchio

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pinocchio

Limestone

Create Solana programs with no dependencies attached.

I've got no dependencies
To hold me down
To make me fret
Or make me frown
I had dependencies
But now I'm free
There are no dependencies on me

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.

Warning

The current version is at work-in-progress stage. While it is already possible to write programs, there are still a few improvements needed — e.g., easy access to cluster sysvars and cross program invocation helpers.

Getting started

From your project folder:

cargo add pinocchio

On your entrypoint definition:

use pinocchio::{
  account_info::AccountInfo,
  entrypoint,
  entrypoint::ProgramResult,
  msg,
  pubkey::Pubkey
};

entrypoint!(process_instruction);

pub fn process_instruction(
  program_id: &Pubkey,
  accounts: &[AccountInfo],
  instruction_data: &[u8],
) -> ProgramResult {
  msg!("Hello from my program!");
  Ok(())
}

Important

You should use the types from the pinocchio crate instead of solana-program. If you need to invoke a different program, you will need to redefine its instruction builder to create an equivalent instruction data using pinocchio types.

License

The code is licensed under the Apache License Version 2.0

The library in this repository is based/includes code from:

About

Create Solana programs with no dependencies attached

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%