This basic implementation is based on "counter" contract, that increment / decrement a value.
- Install Rust (you'll need
rustup
and Cargo). - For our example, install RISC Zero.
- Run a local devnet node:
Clone the hyle repo, checkout the version you need, and run:
export RISC0_DEV_MODE=1
cargo run -- --pg
To build and register the smart contract on the local node, run:
cargo run -- register-contract
The expected output on the node is 📝 Registering contract counter
.
During development, faster iteration upon code changes can be achieved by leveraging dev-mode, we strongly suggest activating it during your early development phase.
RISC0_DEV_MODE=1 cargo run
RISC0_DEV_MODE=1 cargo run -- increment
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
├── contract
│ ├── Cargo.toml
│ └── src
│ └── lib.rs <-- [Contract code goes here, common to host & guest]
├── host
│ ├── Cargo.toml
│ └── src
│ └── main.rs <-- [Host code goes here]
└── methods
├── Cargo.toml
├── build.rs
├── guest
│ ├── Cargo.toml
│ └── src
│ └── main.rs <-- [Guest code goes here]
└── src
└── lib.rs