This project implements a simple lamport vault on Solana using Pinocchio, a lightweight Solana-compatible framework.
Users can securely deposit and withdraw lamports (Solanaβs smallest denomination) into a vault derived from their public key using a Program Derived Address (PDA). Only the original depositor can withdraw the funds.
π‘ Built as part of the Blueshift Pinocchio Vault Challenge
- π₯ Deposit lamports into a vault securely
- π€ Withdraw lamports back to the depositor
- π‘οΈ Enforces PDA ownership and vault uniqueness
- π Rent-exempt checks for deposit safety
- π§ Demonstrates PDA signing and CPI (Cross-Program Invocation)
Make sure you have Rust and the Pinocchio toolchain installed.
# Create a new cargo workspace
cargo new blueshift_vault --lib --edition 2021
cd blueshift_vault
# Add dependencies
cargo add pinocchio pinocchio-systemUpdate your Cargo.toml to support dynamic libraries:
[lib]
crate-type = ["lib", "cdylib"]All logic is implemented inside lib.rs, including:
- Vault PDA Derivation
- Deposit & Withdraw Instructions
- Account Validation & Ownership Checks
- Validates the vault is empty (no double deposits)
- Checks that deposit amount is non-zero and rent-exempt
- Transfers lamports using a CPI to the system program
- Ensures the vault contains lamports
- Re-derives the PDA from the owner's pubkey
- Vault signs the transfer using PDA signing via
invoke_signed
To compile the program for Solanaβs SBF (Sealevel BPF) format:
cargo build-sbfThis will generate a .so file in target/deploy/.
To deploy
solana program deploy target/deploy/example_program.so --program-id ./target/deploy/example_program-keypair.jsonDeployed on devnet:
https://explorer.solana.com/tx/2hoKMpqNnwAsokRfEKqg4rD7ufY9bpZf9sKYEDzam7uKN3NTZuLu9oWkurukSSvxYavdvWPY9ywyNvC3wvFLFf4?cluster=devnetOnce built, go to the Pinocchio Vault Challenge page and upload your .so file to test it and claim your on-chain NFT.
This project is based on the excellent guide by Blueshift.
Special thanks to their educational challenge:
π Pinocchio Vault Challenge
MIT License Β© 2025
Built with β€οΈ by [Your Name or GitHub handle]