From c59150c6b0ecfc75b719e871296eeeb624204edc Mon Sep 17 00:00:00 2001 From: BC-A Date: Wed, 24 Apr 2024 22:54:55 +0800 Subject: [PATCH] chore: update README --- README.md | 20 +++++++++++++++++++- scripts/deploy.js | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4579945..fda979d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Examples +# Deploy contracts using hardhat Run the hardhat node on port 8545 ```shell @@ -17,3 +17,21 @@ Deploy contracts Box and Book, and Box will make function calls based on the add ```shell npx hardhat run scripts/contract_call.js --network localhost ``` + +# Deploy contracts using forge + +Deploy Box contract +```shell +forge create --rpc-url http://localhost:8546 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 contracts/Box.sol:Box +``` + +Deploy Book contract +```shell +forge create --rpc-url http://localhost:8546 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 contracts/Book.sol:Book +``` + +Call the store function in the Box contract, 0x32FcBc51dC71b5A47cD6a7124f432102e2f07334 is the address of the Box contract, 0x6B3920Ed4594BB8c99CeCa979971E93f1F39B6E3 is the address of the Book contract. +```shell +cast send --rpc-url http://localhost:8546 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 0x32FcBc51dC71b5A47cD6a7124f432102e2f07334 "store(address,uint256)" 0x6B3920Ed4594BB8c99CeCa979971E93f1F39B6E3 1 +``` +If the status in the output result is 1, it means that the transaction was successfully executed. diff --git a/scripts/deploy.js b/scripts/deploy.js index aa3974a..e8e39b0 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -9,7 +9,7 @@ const hre = require("hardhat"); async function main() { const [owner] = await ethers.getSigners(); const ownerAddress = await owner.address - const myToken = await hre.ethers.deployContract("MyToken", [ownerAddress]); + const myToken = await hre.ethers.deployContract("MyToken"); console.log('Deploying MyToken...'); myToken.waitForDeployment();