Skip to main content

Host Code 101

In a zkVM application, the host is the machine that is running the zkVM. The host is an untrusted agent that sets up the zkVM environment and handles inputs/outputs during execution.

Note: If you're building for Bonsai, you don't need to write host code.

This page serves as an introduction to writing RISC Zero host code, to help you get started building applications for the zkVM.

The Executor & the Prover

In a zkVM application, the host is responsible for constructing and running the Executor and the Prover.

From Guest Code to Receipt

In more detail, the host will:

  1. Construct an Executor for a guest program,
  2. Run the Executor to construct a session,
  3. Run the Prover to generate a receipt.

The receipt can now be passed to a third-party for verification.

A Very Simple Host

The code shown below is the main() function for a very simple host program. Aside from the absence of any I/O during execution, the host performs exactly the actions described above.

fn main() {
let env = ExecutorEnv::builder().build().unwrap();
let mut exec = default_executor_from_elf(env, METHOD_NAME_ELF).unwrap();
let session =;
let receipt = session.prove().unwrap();

To see more complex examples, check out our examples folder on GitHub.

Verifying Receipts

The functionality for verifying receipts is also included in the risc0-zkvm Rust crate.

The standard workflow is for one party to generate a receipt and pass it to another party for verification, using syntax along these lines:


For more information on passing and verifying receipts, check out our page on Receipts. For practical demos, check out the examples on GitHub.

Happy Building!

Hopefully, this guide and the zkVM Quick Start page will be sufficient for you to build your first zkVM application!

If you run into problems, don't be a stranger! You can file an issue on these docs or the examples, and we're happy to answer questions on Discord.