Skip to content

Commit

Permalink
chore: Update deployment guide (#165)
Browse files Browse the repository at this point in the history
update the deployment-guide.md according to the changes made in this
#138

Co-authored-by: Victor Graf <victor@risczero.com>
  • Loading branch information
PinelliaC and nategraf authored Jul 2, 2024
1 parent 760d0a7 commit 65cefa6
Showing 1 changed file with 29 additions and 40 deletions.
69 changes: 29 additions & 40 deletions examples/erc20-counter/deployment-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,70 +32,58 @@ You can deploy your contracts and run an end-to-end test or demo as follows:
export BONSAI_API_KEY="YOUR_API_KEY" # see form linked in the previous section
export BONSAI_API_URL="BONSAI_API_URL" # provided with your api key
```

4. Deploy the ERC20 Toyken contract:
```
forge script --rpc-url http://localhost:8545 --broadcast script/DeployERC20.s.sol
```
Save the `ERC20 Toyken` contract address to an env variable:
```
export TOYKEN_ADDRESS=#COPY ERC20 TOYKEN ADDRESS FROM DEPLOY LOGS
```

> You can also use the following command to set the contract address if you have [`jq`][jq] installed:
>
> ```bash
> export TOYKEN_ADDRESS=$(jq -re '.transactions[] | select(.contractName == "ERC20") | .contractAddress' ./broadcast/DeployERC20.s.sol/31337/run-latest.json)
> ```

5. Mint some Toyken:
```
cast send --private-key $ETH_WALLET_PRIVATE_KEY --rpc-url http://localhost:8545 $TOYKEN_ADDRESS 'mint(address, uint256)' 0x9737100D2F42a196DE56ED0d1f6fF598a250E7E4 100
```
> Now the account at address `0x9737100D2F42a196DE56ED0d1f6fF598a250E7E4` should have 100 Toyken.

3. Build the project:

Before building the project, make sure the contract address on both the [methods/guest/src/bin/balance_of.rs] as well [apps/src/bin/publisher.rs] is set to the value of your deployed `TOYKEN_ADDRESS`:

```rust
const CONTRACT: Address = address!("<PLACE YOUR TOYKEN ADDRESS HERE>");
```

Then run:

3. Build the Project:
```bash
cargo build
```

4. Deploy the Counter contract by running:


4. Deploy the ERC20 Toyken and Counter contract by running:
```bash
forge script --rpc-url http://localhost:8545 --broadcast script/DeployCounter.s.sol
```

This command should output something similar to:

```bash
...
== Logs ==
Deployed RiscZeroGroth16Verifier to 0x5FbDB2315678afecb367f032d93F642f64180aa3
Deployed Counter to 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
Deployed ERC20 TOYKEN to 0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6
Deployed RiscZeroGroth16Verifier to 0x8A791620dd6260079BF849Dc5567aDC3F2FdC318
Deployed Counter to 0x610178dA211FEF7D417bC0e6FeD39F05609AD788
...
```
Save the `ERC20 Toyken` contract address to an env variable:
```bash
export TOYKEN_ADDRESS=#COPY ERC20 TOYKEN ADDRESS FROM DEPOLY LOGS
```

> You can also use the following command to set the contract address if you have [`jq`][jq] installed:
>
> ```bash
> export TOYKEN_ADDRESS=$(jq -re '.transactions[] | select(.contractName == "ERC20") | .contractAddress' ./broadcast/DeployCounter.s.sol/31337/run-latest.json)
> ```

Save the `Counter` contract address to an env variable:

```bash
export COUNTER_ADDRESS=#COPY COUNTER ADDRESS FROM DEPLOY LOGS
```

> You can also use the following command to set the contract address if you have [`jq`][jq] installed:
>
> ```bash
> export COUNTER_ADDRESS=$(jq -re '.transactions[] | select(.contractName == "Counter") | .contractAddress' ./broadcast/DeployCounter.s.sol/31337/run-latest.json)
> ```

5. Mint some Toyken:
```bash
cast send --private-key $ETH_WALLET_PRIVATE_KEY --rpc-url http://localhost:8545 $TOYKEN_ADDRESS 'mint(address, uint256)' 0x9737100D2F42a196DE56ED0d1f6fF598a250E7E4 100
```
> Now the account at address `0x9737100D2F42a196DE56ED0d1f6fF598a250E7E4` should have 100 Toyken.
>
> You can verify the balance by running:
> ```bash
> cast call $TOYKEN_ADDRESS --rpc-url http://localhost:8545 "balanceOf(address)(uint256)" 0x9737100D2F42a196DE56ED0d1f6fF598a250E7E4
> ```

### Interact with your local deployment

1. Query the state:
Expand All @@ -111,6 +99,7 @@ You can deploy your contracts and run an end-to-end test or demo as follows:
--chain-id=31337 \
--rpc-url=http://localhost:8545 \
--contract=${COUNTER_ADDRESS:?} \
--token=${TOYKEN_ADDRESS:?} \
--account=0x9737100D2F42a196DE56ED0d1f6fF598a250E7E4
```

Expand Down Expand Up @@ -204,7 +193,7 @@ You can deploy the Counter contract on a testnet such as `Sepolia` and run an en
```
[Deploy to a testnet]: #deploy-your-project-on-a-testnet
[Deploy your project to a local network]: #deploy-your-project-on-a-local-network
[Deploy to a local network]: #deploy-on-a-local-network
[RISC Zero]: https://www.risczero.com/
[Node.js]: https://nodejs.org/
[jq]: https://jqlang.github.io/jq/
Expand Down

0 comments on commit 65cefa6

Please sign in to comment.