Skip to content

Learning Solana development by building the same programs twice. Once with Pinocchio and once with Anchor.

Notifications You must be signed in to change notification settings

AlphaR2/Anchor---Native-with-Pinocchio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Solana Programs: Pinocchio & Anchor Implementations

Learning Solana development by building the same programs twice. Once with Pinocchio and once with Anchor.


What This Is

A collection of Solana programs implemented in both Pinocchio and Anchor to understand what frameworks abstract away. Ideally, to understand what Anchor is doing under the hood and how things actually work.

Goal: Deep understanding through dual implementation.

What You'll Find Here

  • Working code - Both implementations fully functional and tested (when marked as done)
  • Side-by-side comparisons - Same logic, different approaches
  • Real performance data - Compute units, binary sizes, development time
  • Honest reflections - What's hard, what's easy, what surprised me
  • Testing examples - Using LiteSVM, Mollusk, and Surfpool for fast, isolated tests

Programs Done So Far (Updated as I Go)

1. Vault Program

  • Pinocchio (with LiteSVM tests)
  • Anchor (in progress)

Structure

solana-programs/
├── vault/
│   ├── pinocchio-vault/    
│   ├── anchor-vault/      
│   └── README.md         
├── escrow/
│   ├── pinocchio-escrow/
│   ├── anchor-escrow/
│   └── README.md
├── ...
└── README.md               # This file

Each program folder contains:

  • Pinocchio implementation - Manual validation, zero-copy, no-std
  • Anchor implementation - Macros, automatic validation, IDL
  • Comparison README - Side-by-side analysis, learnings, benchmarks

Why Both?

Aspect Pinocchio Anchor
Learning How Solana actually works How to ship fast
Control Complete Framework-guided
Development Slower, explicit Faster, implicit
Use Case Core infrastructure, learning Applications, production

Building both reveals the trade-offs and teaches the fundamental concepts that frameworks abstract away.


Quick Start

Prerequisites

solana --version  
rustc --version  
anchor --version 

Run Any Program

Pinocchio:

cd <program>/pinocchio-<program>
cargo build-sbf
cargo test -- --show-output

Anchor:

cd <program>/anchor-<program>
anchor build
anchor test

Key Learnings

What Pinocchio Teaches

  • Manual account validation = security fundamentals
  • Zero-copy patterns (&'a AccountInfo)
  • Explicit CPI mechanics (invoke_signed)
  • PDA derivation and signing
  • Instruction data parsing (discriminators, serialization)

What Anchor Teaches

  • Productivity vs control trade-offs
  • When abstraction helps vs hurts
  • Framework patterns and conventions
  • Rapid iteration workflows

Testing

All programs use modern, fast testing frameworks:


Roadmap

  • Vault (deposit/withdraw SOL)
  • Escrow (atomic token swaps)
  • AMM (constant product)
  • Voting DAO (proposal & voting)
  • NFT Staking
  • Prediction Market

Context

Part of my learning journey (just weekend and fun stuff). Each program deepens understanding of:

  • Account model & ownership
  • Deeper understanding of Rust
  • Key standard procedures for building performant programs
  • Transaction processing
  • Runtime mechanics
  • Gaining vast knowledge and experience

Contributing

This is a learning repository, so it'll be filled with lots of comments. Feedback, questions, and corrections are welcome!

  • Suggest improvements or corrections
  • Please help me test it and comment on improvements
  • Ask questions about implementation choices

About

Learning Solana development by building the same programs twice. Once with Pinocchio and once with Anchor.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published