This template serves as a starter app powered by verifiable compute via Boundless.
It is built around a simple smart contract, EvenNumber
deployed on Sepolia, and its associated RISC Zero guest, is-even
. To get you started, we have deployed to EvenNumber contract to Sepolia; we have also pre-uploaded the is-even
guest to IPFS.
-
curl -L https://risczero.com/install | bash rzup install
-
Clone this repo
You can clone this repo with
git
, or useforge init
:forge init --template https://github.com/boundless-xyz/boundless-foundry-template boundless-foundry-template
-
Set up your environment variables
Export your Sepolia wallet private key as an environment variable (making sure it has enough funds):
export RPC_URL="https://ethereum-sepolia-rpc.publicnode.com" export PRIVATE_KEY="YOUR_PRIVATE_KEY"
You'll also need a deployment of the EvenNumber contract. You can use a predeployed contract on Sepolia:
export EVEN_NUMBER_ADDRESS="0xE819474E78ad6e1C720a21250b9986e1f6A866A3"
-
Run the example app
The example app will 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 using the pre-uploaded zkVM guest:
RUST_LOG=info cargo run --bin app -- --number 4 --program-url https://plum-accurate-weasel-904.mypinata.cloud/ipfs/QmU7eqsYWguHCYGQzcg42faQQkgRfWScig7BcsdM1sJciw
To build the example run:
forge build
cargo build
Test the Solidity smart contracts with:
forge test -vvv
Test the Rust code including the guest with:
cargo test
You can deploy your smart contracts using forge script. To deploy the EvenNumber
contract, run:
VERIFIER_ADDRESS="0x925d8331ddc0a1F0d96E68CF073DFE1d92b69187" forge script contracts/scripts/Deploy.s.sol --rpc-url ${RPC_URL:?} --broadcast -vv
export EVEN_NUMBER_ADDRESS=# address from the logs the script.
This will use the locally build guest binary, which you will need to upload using the steps below.
When you modify your program, you'll need to upload your program to a public URL. You can use any file hosting service, and the Boundless SDK provides built-in support uploading to AWS S3, and to IPFS via Pinata.
If you'd like to upload your program automatically using Pinata:
# The JWT from your Pinata account: https://app.pinata.cloud/developers/api-keys
export PINATA_JWT="YOUR_PINATA_JWT"
Then run without the --program-url
flag:
RUST_LOG=info cargo run --bin app -- --number 4
You can also upload your program to any public URL ahead of time, and supply the URL via the --program-url
flag.