This template serves as a starting point for developing an application with verifiable compute provided by Boundless.
It is built around a simple smart contract, EvenNumber
, and its associated RISC Zero guest, is-even
.
To build the example run:
# Populate the `./lib` submodule dependencies
git submodule update --init --recursive
cargo build
forge build
Test the Solidity smart contracts with:
forge test -vvv
Test the Rust code including the guest with:
cargo test
Export your Sepolia testnet wallet private key as an environment variable:
export WALLET_PRIVATE_KEY="YOUR_WALLET_PRIVATE_KEY"
To allow provers to access your zkVM guest binary, it must be uploaded to a public URL. For this example we will upload to IPFS using Pinata. Pinata has a free tier with plenty of quota to get started. Sign up at [Pinata](https://pinata.cloud/), generate an API key, and set the JWT as an environment variable:
export PINATA_JWT="YOUR_PINATA_JWT"
A .env
file is provided with the Boundless contract deployment information for Sepolia.
The example app reads from this .env
file automatically.
To deploy the EvenNumber
contract run:
. ./.env # load the environment variables from the .env file for deployment
forge script contracts/scripts/Deploy.s.sol --rpc-url ${RPC_URL:?} --broadcast -vv
Save the EvenNumber
contract address to an env variable:
# First contract deployed and top of logs is EvenNumber
export EVEN_NUMBER_ADDRESS=#COPY EVEN NUMBER ADDRESS FROM DEPLOY LOGS
You can also use the following command to set the contract address if you have
jq
installed:export EVEN_NUMBER_ADDRESS=$(jq -re '.transactions[] | select(.contractName == "EvenNumber") | .contractAddress' ./broadcast/Deploy.s.sol/11155111/run-latest.json)
The example app will upload your zkVM guest to IPFS, submit a request to the market for a proof that "4" is an even number, wait for the request to be fulfilled, and then submit that proof to the EvenNumber contract, setting the value to "4".
To run the example:
RUST_LOG=info cargo run --bin app -- --even-number-address ${EVEN_NUMBER_ADDRESS:?} --number 4