How franckinani/mini-vault works
Purpose and Entry Points
Mini Vault is an Anchor-based Solana program, currently implemented as an authority-controlled PDA counter rather than a token/SOL vault. The on-chain instruction handlers and account definitions are centralized in programs/mini-vault/src/lib.rs. The workspace is rooted at Cargo.toml, with Anchor deployment/test settings in Anchor.toml.
On-Chain Program Boundary
The Solana program crate at programs/mini-vault/ compiles Rust/Anchor code into a deployed BPF program. Its declared program ID is the identity clients use to invoke instructions. Anchor supplies account deserialization, signer checks, PDA validation, initialization, and System Program CPI integration.
Grounding paths:
• programs/mini-vault/Cargo.toml
• programs/mini-vault/src/lib.rs
• Anchor.toml
Counter PDA State
Persistent state is a Counter account owned by the program. It stores the numeric counter and the authority public key. The account is derived deterministically as a PDA using the fixed counter seed, providing one canonical state address per deployed program rather than accepting arbitrary counter accounts.
The state model is defined alongside instruction logic:
• programs/mini-vault/src/lib.rs
Initialization Flow
initialize is the state-creation entry point. A payer signs and funds creation of the PDA-backed Counter; the program initializes its count to zero and records the payer as authority. The documented flow also transfers one lamport to the counter account, crossing the program boundary through the Solana System Program.
Key boundaries:
• Payer is the transaction signer and account-creation funder.
• Counter is initialized as a program-owned PDA.
• System Program performs system-level account/lamport operations.
Grounding paths:
• programs/mini-vault/src/lib.rs
• Anchor.toml
Authorized Increment Flow
increment mutates an existing counter. The supplied authority must sign and match the public key stored in Counter; only then can the count advance. Program logic enforces a hard upper bound of 10, preventing further updates once the maximum is reached.
This separates authorization state (stored authority key) from transaction authorization (the signer account):
• programs/mini-vault/src/lib.rs
Runtime and Infrastructure
The project uses Rust 1.89.0 and Cargo, Anchor for Solana program development, and Solana CLI/Anchor CLI for local build, deployment, and testing workflows. Anchor.toml configures Anchor, including the local Solana wallet location. Tests run program interactions against LiteSVM rather than requiring a live cluster.
Grounding paths:
• rust-toolchain.toml
• Anchor.toml
• programs/mini-vault/tests/test_initialize.rs
Verification Boundary
The integration test exercises the externally visible instruction contract: PDA initialization, initial state/authority assignment, and a successful authority increment. It is the current consumer-side validation of account wiring and state transitions.
Grounding path:
• programs/mini-vault/tests/test_initialize.rs
Main entry points: Cargo.toml Mini Vault crate · lib.rs initialize · test_initialize.rs Initialize integration test · Anchor.toml Anchor & Solana CLI
Components 15
Workspace
- Cargo workspace
Cargo.toml - Anchor config · Deployment, test, and wallet settings.
Anchor.toml
On-chain Program
- Mini Vault crate · Compiles to the deployed Solana BPF program.
programs/mini-vault/Cargo.toml - Instructions · initialize and increment entry points.
programs/mini-vault/src/lib.rs - Counter PDA · Canonical `counter`-seeded state holding count and authority.
programs/mini-vault/src/lib.rs - initialize · Creates the PDA, sets count to zero, and records payer authority.
programs/mini-vault/src/lib.rs - increment · Requires stored authority signer and caps count at 10.
programs/mini-vault/src/lib.rs
Runtime & Tooling
- Solana runtime
- Rust 1.89.0
rust-toolchain.toml - Anchor & Solana CLI
Anchor.toml
Verification
- LiteSVM · Runs interactions without a live cluster.
programs/mini-vault/tests/test_initialize.rs - Initialize integration test · Validates PDA initialization, authority assignment, and increment.
programs/mini-vault/tests/test_initialize.rs
Other components
- Payer · Funds PDA creation and becomes authority.
- Authority signer
- System Program · Creates accounts and performs lamport operations.
Connections 18
- Cargo workspace → Mini Vault crate: includes
- Rust 1.89.0 → Mini Vault crate: compiles
- Anchor config → Anchor & Solana CLI: configures
- Anchor & Solana CLI → Mini Vault crate: builds and deploys
- Mini Vault crate → Instructions: contains
- Instructions → initialize: exposes
- Instructions → increment: exposes
- Mini Vault crate → Counter PDA: owns
- initialize → Counter PDA: creates and initializes
- Payer → initialize: signs and funds
- initialize → System Program: CPI for creation and lamports
- increment → Counter PDA: reads and increments
- Authority signer → increment: signs
- Counter PDA → increment: stored authority must match
- Mini Vault crate → Solana runtime: executes on
- Initialize integration test → LiteSVM: runs on
- Initialize integration test → initialize: invokes
- Initialize integration test → increment: validates