GithubHelp home page GithubHelp logo

hello-risc0's Introduction

RISC Zero Rust Starter Template

Welcome to the RISC Zero Rust Starter Template! This template is intended to give you a starting point for building a project using the RISC Zero zkVM. Throughout the template (including in this README), you'll find comments labelled TODO in places where you'll need to make changes. To better understand the concepts behind this template, check out the zkVM Overview.

Quick Start

First, make sure rustup is installed. The rust-toolchain.toml file will be used by cargo to automatically install the correct version.

To build all methods and execute the method within the zkVM, run the following command:

cargo run

This is an empty template, and so there is no expected output (until you modify the code).

Executing the project locally in development mode

During development, faster iteration upon code changes can be achieved by leveraging dev-mode, we strongly suggest activating it during your early development phase. Furthermore, you might want to get insights into the execution statistics of your project, and this can be achieved by specifying the environment variable RUST_LOG="[executor]=info" before running your project.

Put together, the command to run your project in development mode while getting execution statistics is:

RUST_LOG="[executor]=info" RISC0_DEV_MODE=1 cargo run

Running proofs remotely on Bonsai

Note: The Bonsai proving service is still in early Alpha; an API key is required for access. Click here to request access.

If you have access to the URL and API key to Bonsai you can run your proofs remotely. To prove in Bonsai mode, invoke cargo run with two additional environment variables:

BONSAI_API_KEY="YOUR_API_KEY" BONSAI_API_URL="BONSAI_URL" cargo run

How to create a project based on this template

Search this template for the string TODO, and make the necessary changes to implement the required feature described by the TODO comment. Some of these changes will be complex, and so we have a number of instructional resources to assist you in learning how to write your own code for the RISC Zero zkVM:

Directory Structure

It is possible to organize the files for these components in various ways. However, in this starter template we use a standard directory structure for zkVM applications, which we think is a good starting point for your applications.

project_name
├── Cargo.toml
├── host
│   ├── Cargo.toml
│   └── src
│       └── main.rs                        <-- [Host code goes here]
└── methods
    ├── Cargo.toml
    ├── build.rs
    ├── guest
    │   ├── Cargo.toml
    │   └── src
    │       └── bin
    │           └── method_name.rs         <-- [Guest code goes here]
    └── src
        └── lib.rs

Video Tutorial

For a walk-through of how to build with this template, check out this excerpt from our workshop at ZK HACK III.

Questions, Feedback, and Collaborations

We'd love to hear from you on Discord or Twitter.

hello-risc0's People

Contributors

flyq avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.