From ebf192dcfafaccd380046df8c24986c4725b7176 Mon Sep 17 00:00:00 2001 From: sdpbhandari Date: Tue, 26 Sep 2023 01:27:40 +0545 Subject: [PATCH 1/2] update solidity document to deploy tthe contract as well as getting ready with forge commands --- contracts/evm/xcall/README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/contracts/evm/xcall/README.md b/contracts/evm/xcall/README.md index 9265b455..2649ba17 100644 --- a/contracts/evm/xcall/README.md +++ b/contracts/evm/xcall/README.md @@ -48,7 +48,14 @@ $ anvil ### Deploy ```shell -$ forge script script/Counter.s.sol:CounterScript --rpc-url --private-key +export PRIVATE_KEY= + +$ forge script script/CallService.s.sol:CallServiceScript --rpc-url --private-key + +For Example: (deploying the contract on localnet) +$ forge script script/CallService.s.sol:CallServiceScript --fork-url http://localhost:8545 \ +--private-key $PRIVATE_KEY --broadcast + ``` ### Cast From 7f42adb47433b923ebdcce6d57a817d7fea4372a Mon Sep 17 00:00:00 2001 From: sdpbhandari Date: Tue, 26 Sep 2023 01:27:49 +0545 Subject: [PATCH 2/2] update solidity document to deploy tthe contract as well as getting ready with forge commands --- contracts/evm/xcall/README.md | 92 ++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 8 deletions(-) diff --git a/contracts/evm/xcall/README.md b/contracts/evm/xcall/README.md index 2649ba17..806a5585 100644 --- a/contracts/evm/xcall/README.md +++ b/contracts/evm/xcall/README.md @@ -23,15 +23,14 @@ $ forge build ### Test + ```shell -$ forge test +$ forge test -vv ``` -### Format +To learn more about logs and traces, check out the documentation [here](https://book.getfoundry.sh/forge/tests?highlight=-vv#logs-and-traces). -```shell -$ forge fmt -``` +To view all of the supported logging methods, check out the documentation [here](https://book.getfoundry.sh/reference/ds-test#logging). ### Gas Snapshots @@ -40,6 +39,7 @@ $ forge snapshot ``` ### Anvil +You can start the local EVM test network at any time: ```shell $ anvil @@ -58,16 +58,92 @@ $ forge script script/CallService.s.sol:CallServiceScript --fork-url http://loca ``` + ### Cast +Set the CONTRACT_ADDRESS variable in your terminal: -```shell -$ cast +```sh +export CONTRACT_ADDRESS= +``` + +Call initialize on the contract + +```sh +cast send $CONTRACT_ADDRESS "initialize(string)" "ENTER Chain NID HERE" --private-key $PRIVATE_KEY +``` + +We can then use cast to interact with it. + +For read operations, we can use cast call: For Example: + +```sh +cast call $CONTRACT_ADDRESS "admin()(address)" +``` + +For transactions, we can use cast send, passing in a private key and any arguments: + +```sh +cast send $CONTRACT_ADDRESS "setAdmin(address)" 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc --private-key $PRIVATE_KEY +``` + +To test that the greeting has been updated, run the `call` command again: + +```sh +cast call $CONTRACT_ADDRESS "admin()(address)" +``` + + +## Installing packages + +You can install packages using the `forge install` command. + +To try this out, let's install OpenZeppelin Contracts, then we'll use them to create an ERC721 token: + +> You may need to add and commit any changes to your code to `git` in order to run the install script. + +```sh +forge install OpenZeppelin/openzeppelin-contracts +``` + +Next, create a file named `remappings.txt` in the root of the project and add the following configuration: + +``` +@openzeppelin/=lib/openzeppelin-contracts/ +``` + +This will allow us to easily import with the following syntax: + +```solidity +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; +``` + +You can view all of the automatically inferred remappings for the project by running the following command: + +```sh +forge remappings ``` + +### Test coverage + +You can check for test coverage by running the `coverage` command: + +```sh +forge coverage +``` + +To debug in more details what has not been covered, use the `debug` report: + +```sh +forge coverage --report debug +``` + + + ### Help ```shell $ forge --help $ anvil --help $ cast --help -``` +``` \ No newline at end of file