Skip to content

Commit

Permalink
quick pass on other md files
Browse files Browse the repository at this point in the history
  • Loading branch information
nategraf committed Feb 6, 2024
1 parent da00d5d commit bcf8b48
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
9 changes: 4 additions & 5 deletions contracts/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# 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.

<!-- TODO: Change this link once the new repo is live -->

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.
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
16 changes: 11 additions & 5 deletions deployment-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand All @@ -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)'
```
33 changes: 19 additions & 14 deletions methods/README.md
Original file line number Diff line number Diff line change
@@ -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

<!-- TODO: This should have practical instructions on how to actually upload 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/

0 comments on commit bcf8b48

Please sign in to comment.