Skip to content

Commit

Permalink
chore: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
BC-A committed Apr 24, 2024
1 parent ea73db6 commit c59150c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Examples
# Deploy contracts using hardhat

Run the hardhat node on port 8545
```shell
Expand All @@ -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.
2 changes: 1 addition & 1 deletion scripts/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit c59150c

Please sign in to comment.