From 65cefa6b5bbf6f144ff61f547ead243cf6328911 Mon Sep 17 00:00:00 2001 From: PinelliaC Date: Wed, 3 Jul 2024 06:00:06 +0800 Subject: [PATCH] chore: Update deployment guide (#165) update the deployment-guide.md according to the changes made in this https://github.com/risc0/risc0-ethereum/pull/138 Co-authored-by: Victor Graf --- examples/erc20-counter/deployment-guide.md | 69 +++++++++------------- 1 file changed, 29 insertions(+), 40 deletions(-) diff --git a/examples/erc20-counter/deployment-guide.md b/examples/erc20-counter/deployment-guide.md index aa83ccbd..43349377 100644 --- a/examples/erc20-counter/deployment-guide.md +++ b/examples/erc20-counter/deployment-guide.md @@ -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!(""); - ``` - - 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: @@ -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 ``` @@ -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/