Hello-world verification example
The standard hello-world example is a small Solana program used as a clear target for reproducible build and verification work. It shows how a program built with the solana-program API connects its entry point to a fixed Rust and Solana toolchain, then produces a deployable artifact that another build can check.
Standard program purpose
The program in examples/…/lib.rs is the conventional baseline for this example set. Its entry point accepts the normal Solana program inputs, writes Hello, world! to the program log, and returns success without changing account state or reading instruction data.
This narrow behavior keeps program logic separate from build concerns. A difference in the rebuilt artifact is therefore more likely to point to source or toolchain inputs instead of application behavior. The example programs page places this baseline beside the Pinocchio version, which demonstrates the same verification idea through a different framework.
References: examples/…/lib.rs• L1-13
Package configuration
The package configuration defines the example as a Rust 2021 library named hello_world. It asks Cargo for both a normal library output and a deployable C-compatible dynamic library output. The latter gives the Solana build command a program artifact to produce.
The package depends on solana-program with a declared version of 1.14.10. Its feature set also supports common library and cross-program invocation use cases without changing the default example behavior.
The manifest also records Solana CLI version 1.14.13 in its workspace metadata. This gives tools that read the package metadata a declared CLI version to use alongside the Rust and dependency pins.
| Package concern | Role in the example |
|---|---|
| Package and library name | Identifies the Rust package and program output as hello_world |
| Rust edition | Sets the package language edition to 2021 |
| Library outputs | Supports library use and a deployable program artifact |
| Feature choices | Supports entry-point removal, IDL and log-name controls, CPI use, and test builds |
| Solana dependency | Supplies the standard Solana program API and is locked with the package dependency graph |
| Solana CLI metadata | States the CLI version associated with the package tooling |
The lock file records the resolved dependency graph used by the example. It resolves the solana-program package to 1.14.13, so the declared dependency range and the committed lock state both matter when a verification build is reproduced.
References: examples/…/Cargo.toml• L1-22 examples/…/Cargo.lock• L429-433 examples/…/Cargo.lock• L1001-1048
Toolchain selection
The example pins Rust through examples/…/rust-toolchain.toml, which selects Rust 1.75.0. This pin gives local and container-based builds a common Rust compiler instead of allowing the host's default compiler to decide the result.
The Solana side of the toolchain comes from the build image used by the example Docker definition. Together, the Rust declaration and the image choice form the build environment that must remain aligned with the dependency graph and the deployed artifact.
The build verification execution page explains how this selected environment fits into the wider build, deploy, and verification process.
References: examples/…/rust-toolchain.toml• L1-2 examples/…/hello_world.dockerfile• L1-3
Container build definition
The example Docker definition provides a repeatable build shape for the standard program. It starts from the ellipsislabs/solana:latest image, obtains the repository source at a fixed commit, and runs the Solana SBF build from the example directory.
The build command uses --locked and --frozen. These flags make the build use the committed lock file and reject dependency or lock-file changes. The resulting container step therefore tests the example against its recorded dependency graph rather than silently resolving a new one.
The flow below shows how the image, source revision, package lock, and SBF artifact relate.
flowchart LR
A[Solana build image] --> B[Toolchain environment]
C[Repository at fixed commit] --> D[Hello-world package]
B --> D
E[Committed Cargo.lock] --> D
D --> F[Locked and frozen SBF build]
F --> G[Program artifact]
The Docker definition is an example build path, not a complete deployment or verification command. After the artifact is built and deployed, the verification flow compares a later build with the deployed program. See build verification execution for that system-level flow.
References: examples/…/hello_world.dockerfile• L1-7 examples/…/Cargo.lock• L1-3
Verification role
This example makes the source-to-artifact link easy to inspect. A verifier can use the same source revision, package lock, Rust pin, and Solana build image to rebuild the program. The comparison then asks whether that rebuilt artifact matches the deployed artifact.
The example does not establish that the program is safe or useful. It only provides a small and controlled program whose build inputs can be made visible for verification.
References: examples/…/lib.rs• L6-13 examples/…/hello_world.dockerfile• L2-7 examples/…/rust-toolchain.toml• L1-2
Change checklist
When these files or sections are changed, remember to consider these:
- If the package output name or crate type changes, check the artifact name and the verification target used by the build flow.
- If the
solana-programversion or feature set changes, refresh the lock state and review whether the selected Solana image still supports the package. - If the Rust toolchain pin changes, review the container build and any instructions that claim the example is reproducible.
- If the Solana CLI metadata version changes, review the tool that consumes the package metadata and the matching build environment.
- If the Docker base image or checked-out source revision changes, treat the build inputs as changed even when the Rust source is unchanged.
- If the entry-point behavior changes, keep the standard example page and the sibling Pinocchio hello-world example clear about which behavior is shared.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
The build uses a different Rust compiler from the pinned 1.75.0 toolchain | The rebuilt program can differ from the reference artifact | Use the toolchain declaration for local and container builds |
The lock file is missing or the build omits --locked --frozen | Cargo can resolve a different dependency graph | Keep the committed lock file and strict build flags in use |
The Docker base image changes behind the latest tag | The Solana build environment can change without a source change | Record and review the image used for a verification build |
| The container checks out a different repository commit | The artifact no longer represents the source under review | Build and verify the same public source revision |
| The package output or name no longer matches the verification target | The build may produce an unexpected artifact or fail to locate it | Keep Cargo package settings aligned with the verification workflow |
| The package metadata names a CLI version that does not match the build environment | Tooling can use a different Solana CLI from the one expected by the example | Keep the metadata version and selected build toolchain aligned |
Key files
| File | Why to read it |
|---|---|
| examples/…/lib.rs | Shows the baseline entry point and the complete program behavior |
| examples/…/Cargo.toml | Defines the package identity, outputs, features, Solana API dependency, and CLI metadata |
| examples/…/Cargo.lock | Records the resolved dependency graph used by the strict build |
| examples/…/rust-toolchain.toml | Pins the Rust compiler used by the example |
examples/hello_world/hello_world.dockerfile | Defines the container source checkout and Solana SBF build path |
| docs/example-programs.md | Places the standard example in the set of supported hello-world verification examples |
| docs/build-verification-execution.md | Explains how the built artifact enters the wider verification flow |