diff --git a/contracts/README.md b/contracts/README.md index ca883838..7ed739bc 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -1,8 +1,10 @@ -# Bonsai Solidity Contracts +# Solidity Contracts -This directory contains the Solidity contract for deploying a [Bonsai] application. +This directory contains the Solidity contract for deploying an application with [RISC Zero] on Ethereum. There are two primary starter template contracts included. + + The Solidity libraries for Bonsai can be found at [github.com/risc0/risc0](https://github.com/risc0/risc0/tree/main/bonsai/ethereum). Contracts are built and tested with [forge], which is part of the [Foundry] toolkit. @@ -10,7 +12,4 @@ Tests are defined in the `tests` directory in the root of this template. [Foundry]: https://getfoundry.sh/ [forge]: https://github.com/foundry-rs/foundry#forge -[Bonsai]: https://dev.bonsai.xyz -[offloading the computation]: https://twitter.com/RiscZero/status/1677316664772132864 [RISC Zero]: https://risczero.com -[guest]: https://github.com/risc0/bonsai-foundry-template/tree/main/methods/guest/src/bin diff --git a/deployment-guide.md b/deployment-guide.md index 44b897a7..75188cfe 100644 --- a/deployment-guide.md +++ b/deployment-guide.md @@ -64,7 +64,7 @@ You can deploy your contracts and run an end-to-end test or demo as follows: You can also use the following command to set the contract address if you have `jq` installed: ```bash - export EVEN_NUMBER_ADDRESS=$(jq -r '.transactions[] | select(.contractName == "EvenNumber") | .contractAddress' ./broadcast/Deploy.s.sol/31337/run-latest.json) + export EVEN_NUMBER_ADDRESS=$(jq -re '.transactions[] | select(.contractName == "EvenNumber") | .contractAddress' ./broadcast/Deploy.s.sol/31337/run-latest.json) ``` ### Interact with your local deployment @@ -96,7 +96,7 @@ You can deploy your contracts and run an end-to-end test or demo as follows: You can deploy your contracts on a testnet such as `Sepolia` and run an end-to-end test or demo as follows: -1. Get access to Bonsai and an Ethereum node running on a given testnet, e.g., Sepolia (in this example, we will be using [alchemy](https://www.alchemy.com/) as our Ethereum node provider) and export the following environment variables: +1. Get access to Bonsai and an Ethereum node running on a given testnet, e.g., Sepolia (in this example, we will be using [Alchemy](https://www.alchemy.com/) as our Ethereum node provider) and export the following environment variables: > ***Note:*** *This requires having access to a Bonsai API Key. To request an API key [complete the form here](https://bonsai.xyz/apply).* ```bash @@ -109,7 +109,7 @@ You can deploy your contracts on a testnet such as `Sepolia` and run an end-to-e 2. Deploy your contract by running: ```bash - forge script script/Deploy.s.sol --rpc-url https://eth-sepolia.g.alchemy.com/v2/$ALCHEMY_API_KEY --broadcast + forge script script/Deploy.s.sol --rpc-url https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY:?} --broadcast ``` This command should output something similar to: @@ -131,7 +131,7 @@ You can deploy your contracts on a testnet such as `Sepolia` and run an end-to-e You can also use the following command to set the contract address if you have `jq` installed: ```bash - export EVEN_NUMBER_ADDRESS=$(jq -r '.transactions[] | select(.contractName == "EvenNumber") | .contractAddress' ./broadcast/Deploy.s.sol/11155111/run-latest.json) + export EVEN_NUMBER_ADDRESS=$(jq -re '.transactions[] | select(.contractName == "EvenNumber") | .contractAddress' ./broadcast/Deploy.s.sol/11155111/run-latest.json) ``` ### Interact with your testnet deployment @@ -145,10 +145,16 @@ You can deploy your contracts on a testnet such as `Sepolia` and run an end-to-e 2. Publish a new state ```bash - RISC0_DEV_MODE=false cargo run --release -- publish \ + cargo run --release -- publish \ --chain-id=11155111 \ --rpc-url=https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY:?} \ --contract=${EVEN_NUMBER_ADDRESS:?} \ --guest-binary="IS_EVEN" \ --input=12345678 ``` + +3. Query the state again to see the change: + + ```bash + cast call --rpc-url https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY:?} ${EVEN_NUMBER_ADDRESS:?} 'get()(uint256)' + ``` diff --git a/methods/README.md b/methods/README.md index bec6d13b..cc2b8c27 100644 --- a/methods/README.md +++ b/methods/README.md @@ -1,33 +1,38 @@ -## zkVM Methods +# zkVM Methods -This directory contains the [zkVM] portion of your [Bonsai] application. +This directory contains the [zkVM] portion of your [RISC Zero] application. This is where you will define one or more [guest programs] to act as a coprocessor to your [on-chain logic]. -> In typical use cases, the only code in this directory that you will need to edit is inside [`guest/src/bin`]. +> In typical use cases, the only code in this directory that you will need to edit is inside [`guest/src/bin`]. + +[zkVM]: https://dev.risczero.com/zkvm +[RISC Zero]: https://www.risczero.com/ +[guest programs]: https://dev.risczero.com/terminology#guest-program +[on-chain logic]: ../contracts/ +[`guest/src/bin`]: ./guest/src/bin/ ### Writing Guest Code -To learn to write code for the zkVM, we recommend [Guest Code 101]. + +To learn to write code for the zkVM, we recommend [Guest Code 101]. Examples of what you can do in the guest can be found in the [RISC Zero examples]. +[Guest Code 101]: https://dev.risczero.com/zkvm/developer-guide/guest-code-101 +[RISC Zero examples]: https://github.com/risc0/tree/v0.18.0/examples + ### From Guest Code to Binary File -Code in the `methods/guest` directory will be compiled into one or more [RISC-V] binaries. +Code in the `methods/guest` directory will be compiled into one or more binaries. + Build configuration for the methods is included in `methods/build.rs`. Each will have a corresponding image ID, which is a hash identifying the program. ### Uploading Binary to Bonsai + + + When [deploying] your application, you will upload your binary to Bonsai where the guest will run when requested. The image ID will be included in the deployment of the smart contracts to reference your guest program living in Bonsai. [deploying]: ../deployment-guide -[RISC Zero examples]: https://github.com/risc0/tree/v0.18.0/examples -[Guest Code 101]: https://dev.risczero.com/zkvm/developer-guide/guest-code-101 -[on-chain logic]: ../contracts/readme -[`guest/src/bin`]: ./guest/src/bin/ -[guest program]: https://dev.risczero.com/terminology#guest-program -[guest programs]: https://dev.risczero.com/terminology#guest-program -[developer documentation]: https://dev.risczero.com -[zkVM]: https://dev.risczero.com/zkvm -[Bonsai]: https://dev.risczero.com/bonsai/