Introducing a new way to review your PRs.

Read the announcement

solana-foundation / solana-verifiable-build

CLI tool for deterministically building and verifying executable against on-chain programs or buffer accounts

View on GitHub

18 documents · Updated Nov 23, 2026

docs / anchor-hello-world-example

Anchor hello-world example

The Anchor hello-world example is a small Solana program fixture for checking verifiable builds through the Anchor framework. It combines an Anchor project configuration with a Cargo package so the build system can produce a deployable program and compare its executable hash with a known result.

Program purpose

The program in examples/…/lib.rs defines one Anchor instruction named initialize. That instruction writes Hello, world! to the program log and returns success. It does not read or change account state, so the fixture keeps program behavior simple while the verification process checks the build result.

The instruction uses an empty account context. This means the example exercises Anchor's instruction and account declaration model without adding application state or account rules that could hide the build-focused purpose.

References: examples/…/lib.rs• L1-16

Anchor project configuration

The Anchor configuration in examples/…/Anchor.toml connects the project to a local Solana cluster. It assigns the program ID Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS to hello_world and selects the local Solana wallet as the provider identity.

The configuration also enables feature resolution and keeps Anchor lint checks active. These settings make the project use the expected Anchor project rules when it is built or verified.

Configuration areaRole in the fixture
Localnet program mappingAssociates the Cargo program with its deployed program ID
ProviderSelects the local cluster and wallet for Anchor operations
Feature settingsControls dependency feature resolution and lint behavior

References: examples/…/Anchor.toml• L1-12

Cargo project

The Cargo project packages hello_world as both a Rust library and a deployable C-compatible library. Its Anchor framework dependency supplies the program interface and the build conventions used by the fixture.

The feature set supports normal builds as well as cases where the entry point, IDL, or instruction log name must be omitted. The default feature set stays empty, while the idl-build feature connects IDL generation to Anchor's build support. Cargo metadata also identifies Solana CLI version 4.3.0 for the project toolchain.

The committed lock file records the resolved dependency graph. It is part of the build input when another run must reproduce the reference executable.

References: examples/…/Cargo.toml• L1-28 examples/…/Cargo.lock• L1-3 examples/…/Cargo.lock• L138-145 examples/…/Cargo.lock• L725-734

Verification fixture

The Anchor project is one of the local examples exercised by the verification tests. The test builds from examples/hello_world_anchor, reads target/deploy/hello_world.so, and compares its hash with the fixture value ec383d8f2c815a4855521f442af9470a2ab5a8e0fa61a36bd1463aa5a7e93134.

This check shows that the verification flow can handle an Anchor project as well as the standard and Pinocchio hello-world projects. The example programs page gives the wider comparison, while the standard hello-world example and Pinocchio hello-world example describe the sibling fixtures.

The diagram shows how the Anchor source and project inputs become the executable that the local verification check measures.

flowchart LR
    A[Anchor source] --> C[Anchor Cargo project]
    B[Anchor.toml] --> C
    L[Cargo.lock] --> C
    C --> D[Local Solana build]
    D --> E[hello_world.so]
    E --> F[Executable hash]
    F --> G[Compare with expected fixture hash]

The expected hash confirms that the selected source and build inputs produce the known artifact. It does not prove that the program is safe or that the application meets a wider business need.

References: src/test.rs• L201-210 examples/…/lib.rs• L5-12 examples/…/Anchor.toml• L7-12 examples/…/Cargo.toml• L1-19

Framework comparison

The Anchor fixture shares the hello-world behavior with the other examples, but it expresses the program through Anchor's program and account declarations. This makes it useful for checking that verification supports a framework-managed Solana project rather than only a direct Solana SDK or low-level program interface.

FixtureMain development approachVerification role
Anchor hello-worldAnchor frameworkChecks an Anchor project and its local project configuration
Standard hello-worldsolana-program APIProvides the conventional SDK baseline
Pinocchio hello-worldPinocchio frameworkChecks a project with a different program interface and toolchain path

References: examples/…/lib.rs• L1-16 examples/…/Cargo.toml• L1-19 examples/…/Cargo.toml• L1-21

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the program ID in Anchor.toml and declare_id! aligned. A mismatch can make Anchor operations target a different program.
  • Keep the Cargo package name, deployable output name, and verification executable path aligned.
  • Recheck the expected executable hash when the Anchor version, feature set, dependency lock, or Solana CLI metadata changes.
  • Keep the localnet provider settings aligned with the environment used to exercise the fixture.
  • Update the parent example page and sibling links if the Anchor fixture's role or shared hello-world behavior changes.

Important failure modes

TriggerConsequenceGuard
Anchor.toml and declare_id! use different program IDsAnchor commands and the built program refer to different identitiesKeep both declarations equal
Cargo dependencies or features change without a refreshed lock stateThe build can produce a different executable from the reference fixtureTreat Cargo.lock and the manifest as one build input
The package or output name changes without a test-path updateHash verification cannot find the expected hello_world.soKeep Cargo names aligned with the local verification path
The local provider points to the wrong cluster or walletAnchor actions can run against the wrong deployment targetUse the configured localnet provider for this fixture
The source or toolchain changes while the expected hash stays fixedThe local verification check reports a hash mismatchRebuild the reference hash whenever build inputs change

Key files

FileWhy to read it
examples/…/lib.rsDefines the Anchor instruction and its minimal hello-world behavior
examples/…/Anchor.tomlConnects the project identity, localnet provider, and Anchor feature settings
examples/…/Cargo.tomlDefines the package outputs, Anchor features, dependency, and Solana CLI metadata
examples/…/Cargo.lockRecords the resolved dependency graph for a repeatable build
src/test.rsShows the local build target, executable path, and expected hash used for verification
docs/example-programs.mdPlaces the Anchor fixture beside the other hello-world verification examples
docs/hello-world-example.mdExplains the conventional Solana SDK comparison fixture
docs/pinocchio-hello-world-example.mdExplains the Pinocchio comparison fixture