Example Solana programs
The example programs are small Solana programs used to show how verifiable builds work across three supported development approaches. They keep the on-chain behavior simple so that engineers can focus on whether the same source and build inputs produce the same deployed artifact.
Program set
The repository uses three hello-world programs as comparable build targets. Each program exposes a small on-chain entry point and writes a hello-world message, but each uses a different Solana programming approach.
| Example | Development approach | Build concern | Guide |
|---|---|---|---|
| Standard hello-world | The conventional solana-program API | Uses the Solana program SDK and declares the Solana CLI version for the build | Standard hello-world example |
| Anchor hello-world | The Anchor framework | Uses Anchor project settings and a locked dependency graph | Anchor hello-world example |
| Pinocchio hello-world | The Pinocchio framework | Uses project metadata to identify the Solana CLI needed for the build | Pinocchio hello-world example |
Standard hello-world program
The standard hello-world program is the baseline example for a Solana program built with the conventional solana-program API. Its entry point accepts the normal program inputs and returns success after it emits the shared hello-world message. This makes it a small target for checking that source code and a built program match.
The program declares both library and deployable program outputs. Its package also declares the Solana SDK, common feature choices, and the Solana CLI version used by the build. The dedicated standard hello-world guide covers this example's build and verification path.
References: examples/…/lib.rs• L1-13 examples/…/Cargo.toml• L1-22
Anchor hello-world program
The Anchor hello-world program demonstrates the same basic behavior through the Anchor framework. Anchor supplies the program structure and a named initialize instruction, so this example shows how verifiable builds apply when a framework defines part of the program interface.
The example identifies its localnet program address in Anchor.toml and keeps its resolved Rust dependency graph in Cargo.lock. Its package metadata also identifies the Solana CLI version for the build. The dedicated Anchor hello-world guide covers this example's build and verification path.
References: examples/…/lib.rs• L1-16 examples/…/Anchor.toml• L1-12 examples/…/Cargo.toml• L1-28 examples/…/Cargo.lock• L1-3 examples/…/Cargo.lock• L724-729
Pinocchio hello-world program
The Pinocchio hello-world program demonstrates the same basic program behavior through the Pinocchio framework. It is useful for verification work because it does not rely on solana-program; its package metadata identifies the Solana CLI version that the build process should use.
The program emits the hello-world message and accepts only a non-zero program address. An invalid zero address produces a program ID error. The dedicated Pinocchio hello-world guide explains the build and verification path for this approach.
References: examples/…/lib.rs• L1-17 examples/…/Cargo.toml• L1-20
Verification workflow
The examples support the same high-level verification exercise: build a program from public source, deploy the resulting artifact, and compare a later build with the deployed program. The comparison is meaningful only when the build uses the toolchain, dependency graph, program settings, and source revision described by the example.
The flow below shows how each example fits into the wider verified-build process.
flowchart LR
A[Example source and build inputs] --> B[Solana build environment]
B --> C[Program artifact]
C --> D[Deploy to Solana]
A --> E[Build from public repository]
E --> F[Compare with deployed artifact]
D --> F
F --> G[Verification result]
The standard example uses the Solana SDK and declares its CLI choice in package metadata. The Anchor example adds framework project settings and a locked dependency graph. The Pinocchio example records its Solana CLI choice in package metadata because its dependencies do not provide the usual solana-program version signal. In all three cases, the goal is to make the build inputs clear enough for another party to reproduce the artifact.
References: examples/…/Cargo.toml• L18-22 examples/…/Anchor.toml• L1-12 examples/…/Cargo.toml• L18-28 examples/…/Cargo.toml• L10-20 README.md• L24-52
Example boundaries
These programs demonstrate the mechanics of verifiable builds rather than complete application features. Their small instruction surface keeps differences in framework choice and build selection separate from business logic.
The examples do not by themselves prove that a program is safe. A verification result shows that the deployed artifact matches the selected public source and build inputs; engineers must still review the source and use a trusted build environment.
References: examples/…/lib.rs• L6-13 examples/…/lib.rs• L5-16 examples/…/lib.rs• L6-17 README.md• L58-70
Change checklist
When these files or sections are changed, remember to consider these:
- If an example changes its Solana framework or removes the dependency used to infer the build toolchain, update the build-version metadata and the related child guide together.
- If the standard example changes its Rust or Solana toolchain, review the container build path and any verification instructions that depend on that toolchain.
- If the Anchor example changes its program address, keep
declare_id!, the Anchor localnet program map, and the child guide aligned. - If the Anchor dependency declarations change, keep Cargo.lock and the build instructions aligned with the resolved dependency graph.
- If the entry-point behavior changes, keep the child pages clear about which behavior is shared and which behavior is specific to one example.
- If an example is added or removed, update the program set table and the links to the supported development approaches.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The Anchor program address differs between src/lib.rs and Anchor.toml | Local deployment and later verification can refer to different program identities | Keep the declared ID and the localnet program map equal |
| The Anchor lock file does not match the package dependency declarations | A rebuild can use a different dependency graph from the documented example | Keep the lock file aligned with Cargo.toml |
| The build uses different Rust, Solana CLI, framework, or dependency inputs from the published example | The rebuilt artifact can differ from the deployed artifact | Use the toolchain and project inputs that belong to the selected example |
| The deployed program is checked against a different source revision | Verification does not describe the deployed source | Build and verify the same public repository revision |
| The Pinocchio program receives the zero address | The program returns IncorrectProgramId instead of success | Use the deployed program's non-zero address when exercising the example |
Key files
| File | Why to read it |
|---|---|
| examples/…/lib.rs | Shows the conventional program entry point and shared hello-world behavior |
| examples/…/Cargo.toml | Defines the standard example's program outputs, SDK dependency, and CLI metadata |
examples/hello_world/hello_world.dockerfile | Shows the container-based build path for the standard example |
| examples/…/rust-toolchain.toml | Identifies the Rust toolchain used by the standard example |
| examples/…/lib.rs | Shows the Anchor instruction and program identity |
| examples/…/Anchor.toml | Defines the Anchor localnet program mapping and provider settings |
| examples/…/Cargo.toml | Defines the Anchor package, framework dependency, and CLI metadata |
| examples/…/Cargo.lock | Records the resolved dependency graph used by the Anchor example |
| examples/…/lib.rs | Shows the Pinocchio entry point, message, and program ID check |
| examples/…/Cargo.toml | Defines the Pinocchio dependencies and Solana CLI version metadata |
| README.md | Describes the repository's verified-build purpose and the general build, deploy, and verify flow |