This basic implementation is based on "counter" contract, that increment / decrement a value.
- Install Rust (you'll need
rustup
and Cargo). - SP1 4.1.x
- Run a local devnet node:
Clone the hyle repo, checkout the version you need, and run:
export SP1_PROVER=mock
cargo run -F sp1 -- --pg
Note: you need the "sp1" feature on the node: it is enabled with -F sp1
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.
SP1_PROVER=mock cargo run
SP1_PROVER=mock 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
├── lib
│ ├── Cargo.toml
│ └── src
│ └── lib.rs <-- [Contract code goes here, common to program & script]
├── program
│ ├── Cargo.toml
│ └── src
│ └── main.rs <-- [Program code goes here (runs in the zkvm)]
└── script
├── Cargo.toml
├── build.rs
└── src
└── bin
└── main.rs <-- [Script code goes here (aka application backend)]