From 92b236ee32d09ffe0f1d79e56c68390aea90f9e0 Mon Sep 17 00:00:00 2001
From: port <108868128+portdeveloper@users.noreply.github.com>
Date: Fri, 21 Feb 2025 12:07:05 +0300
Subject: [PATCH 1/7] Update README.md
---
README.md | 106 +++++++++++++++++++++++++-----------------------------
1 file changed, 48 insertions(+), 58 deletions(-)
diff --git a/README.md b/README.md
index c3d9da7..f16d170 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,4 @@
-## Foundry-Monad
-
-> [!NOTE]
-> In this foundry template the default chain is `monadTestnet`, if you wish to change it change the network in `foundry.toml`
-
-
-
-_Foundry-Monad is a Foundry template with Monad configuration. So developers don't have to do the initial configuration in Foundry for Monad network._
+## Monad flavored Foundry
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
@@ -19,87 +9,68 @@ Foundry consists of:
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
-## Requirements
-
-Before you begin, you need to install the following tools:
-
-- Rust
-- Cargo
-- [Foundryup](https://book.getfoundry.sh/getting-started/installation)
-
-## Quickstart
+## Documentation
-To get started, follow the steps below:
+https://book.getfoundry.sh/
-1. You can either clone this repo using the below command:
+## Usage
-```sh
-git clone https://github.com/monad-developers/foundry-monad
-```
-
-or
-
-You can do it manually using the below set of commands:
+### Build
-```sh
-mkdir [project_name] && cd [project_name] && forge init --template monad-developers/foundry-monad
+```shell
+forge build
```
-The foundry project is now ready to be used!
-
-## Examples
-
-### Compile
+### Test
```shell
-forge compile
+forge test
```
-### Build
+### Format
```shell
-forge build
+forge fmt
```
-### Test
+### Gas Snapshots
```shell
-forge test
+forge snapshot
```
-### Deploy
+### Anvil
```shell
-forge create --private-key src/Counter.sol:Counter
+anvil
```
-### Verify Contract
+### Deploy to Monad Testnet
+
+First, you need to create a keystore file. Do not forget to remember the password! You will need it to deploy your contract.
```shell
-forge verify-contract \
- \
- src/Counter.sol:Counter \
- --verify \
- --verifier sourcify \
- --verifier-url https://sourcify-api-monad.blockvision.org
+cast wallet import monad-deployer --private-key $(cast wallet new | grep 'Private key:' | awk '{print $3}')
```
-### Format
+After creating the keystore, you can read its address using:
```shell
-forge fmt
+cast wallet address --account monad-deployer
```
-### Gas Snapshots
+The command above will create a keystore file named `monad-deployer` in the ~/.foundry/keystores directory.
+
+Then, you can deploy your contract to the Monad Testnet using the keystore file you created.
```shell
-forge snapshot
+forge create src/Counter.sol:Counter --rpc-url https://testnet-rpc2.monad.xyz/52227f026fa8fac9e2014c58fbf5643369b3bfc6 --account monad-deployer --broadcast
```
-### Anvil
+## Verify Your Contract on Monad Testnet
```shell
-anvil
+forge verify-contract --chain-id 10143 --verifier sourcify --verifier-url https://sourcify-api-monad.blockvision.org
```
### Cast
@@ -112,12 +83,31 @@ cast
```shell
forge --help
+anvil --help
+cast --help
```
+
+## FAQ
+
+### Error: `Error: server returned an error response: error code -32603: Signer had insufficient balance`
+
+This error happens when you don't have enough balance to deploy your contract. You can check your balance with the following command:
+
```shell
-anvil --help
+cast wallet address --account monad-deployer
+```
+
+### I have constructor arguments, how do I deploy my contract?
+
+```shell
+forge create src/Counter.sol:Counter --rpc-url https://testnet-rpc2.monad.xyz/52227f026fa8fac9e2014c58fbf5643369b3bfc6 --account monad-deployer --broadcast --constructor-args
```
+### I have constructor arguments, how do I verify my contract?
+
```shell
-cast --help
+forge verify-contract --chain-id 10143 --verifier sourcify --verifier-url https://sourcify-api-monad.blockvision.org --constructor-args
```
+
+Please refer to the [Foundry Book](https://book.getfoundry.sh/) for more information.
\ No newline at end of file
From 2a185265d79e0f02fc3df7570b09320d23179023 Mon Sep 17 00:00:00 2001
From: port <108868128+portdeveloper@users.noreply.github.com>
Date: Fri, 21 Feb 2025 12:07:41 +0300
Subject: [PATCH 2/7] Update test.yml to latest from original hello_foundry
repo
---
.github/workflows/test.yml | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 9282e82..34a4a52 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,6 +1,9 @@
-name: test
+name: CI
-on: workflow_dispatch
+on:
+ push:
+ pull_request:
+ workflow_dispatch:
env:
FOUNDRY_PROFILE: ci
@@ -19,12 +22,18 @@ jobs:
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- with:
- version: nightly
- - name: Run Forge build
+ - name: Show Forge version
run: |
forge --version
+
+ - name: Run Forge fmt
+ run: |
+ forge fmt --check
+ id: fmt
+
+ - name: Run Forge build
+ run: |
forge build --sizes
id: build
From 0eb5fca246ca34cf9e1d7f7ee68ba15637aa3c9e Mon Sep 17 00:00:00 2001
From: port <108868128+portdeveloper@users.noreply.github.com>
Date: Fri, 21 Feb 2025 12:36:03 +0300
Subject: [PATCH 3/7] Remove explicit rpc url flag from forge create in readme
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index f16d170..2ea7bf8 100644
--- a/README.md
+++ b/README.md
@@ -64,7 +64,7 @@ The command above will create a keystore file named `monad-deployer` in the ~/.f
Then, you can deploy your contract to the Monad Testnet using the keystore file you created.
```shell
-forge create src/Counter.sol:Counter --rpc-url https://testnet-rpc2.monad.xyz/52227f026fa8fac9e2014c58fbf5643369b3bfc6 --account monad-deployer --broadcast
+forge create src/Counter.sol:Counter --account monad-deployer --broadcast
```
## Verify Your Contract on Monad Testnet
@@ -101,7 +101,7 @@ cast wallet address --account monad-deployer
### I have constructor arguments, how do I deploy my contract?
```shell
-forge create src/Counter.sol:Counter --rpc-url https://testnet-rpc2.monad.xyz/52227f026fa8fac9e2014c58fbf5643369b3bfc6 --account monad-deployer --broadcast --constructor-args
+forge create src/Counter.sol:Counter --account monad-deployer --broadcast --constructor-args
```
### I have constructor arguments, how do I verify my contract?
From 7c52bec29aba8ba680152a8689ac13e2c839e294 Mon Sep 17 00:00:00 2001
From: port <108868128+portdeveloper@users.noreply.github.com>
Date: Tue, 25 Feb 2025 08:23:53 +0300
Subject: [PATCH 4/7] Use a number as chain_id
---
foundry.toml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/foundry.toml b/foundry.toml
index 03f155d..c2862d2 100644
--- a/foundry.toml
+++ b/foundry.toml
@@ -5,6 +5,6 @@ libs = ["lib"]
# Monad Configuration
eth-rpc-url="https://testnet-rpc.monad.xyz"
-chain_id = "10143"
+chain_id = 10143
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
From f2758ee0fe00f8a4b23e77673236126b05e69a39 Mon Sep 17 00:00:00 2001
From: port <108868128+portdeveloper@users.noreply.github.com>
Date: Sun, 2 Mar 2025 20:06:08 +0300
Subject: [PATCH 5/7] Update README with minor styling fixes
---
README.md | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index b060481..44d5ee0 100644
--- a/README.md
+++ b/README.md
@@ -43,14 +43,15 @@ forge snapshot
```shell
anvil
-=======
+```
### Deploy to Monad Testnet
First, you need to create a keystore file. Do not forget to remember the password! You will need it to deploy your contract.
-
+```shell
cast wallet import monad-deployer --private-key $(cast wallet new | grep 'Private key:' | awk '{print $3}')
+```
After creating the keystore, you can read its address using:
@@ -58,7 +59,7 @@ After creating the keystore, you can read its address using:
cast wallet address --account monad-deployer
```
-The command above will create a keystore file named `monad-deployer` in the ~/.foundry/keystores directory.
+The command above will create a keystore file named `monad-deployer` in the `~/.foundry/keystores` directory.
Then, you can deploy your contract to the Monad Testnet using the keystore file you created.
@@ -66,7 +67,7 @@ Then, you can deploy your contract to the Monad Testnet using the keystore file
forge create src/Counter.sol:Counter --account monad-deployer --broadcast
```
-## Verify Your Contract on Monad Testnet
+### Verify your contract on Monad Testnet
```shell
forge verify-contract --chain-id 10143 --verifier sourcify --verifier-url https://sourcify-api-monad.blockvision.org
From 66b6b76af01e12537410eace4ca6f8bc63f2b738 Mon Sep 17 00:00:00 2001
From: Keone Hon
Date: Sun, 2 Mar 2025 18:07:31 -0500
Subject: [PATCH 6/7] restore a few features of README.md from the previous
version
---
README.md | 30 ++++++++++++++++++++++--------
1 file changed, 22 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index 44d5ee0..a21a76e 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,20 @@
-## Monad flavored Foundry
+## Monad-flavored Foundry
+
+> [!NOTE]
+> In this Foundry template, the default chain is `monadTestnet`, If you wish to change it, change the network in `foundry.toml`
+
+
+
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
Foundry consists of:
-- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
-- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
+- **Forge**: Ethereum testing framework (like Truffle, Hardhat, and DappTools).
+- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions, and getting chain data.
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
@@ -67,14 +76,19 @@ Then, you can deploy your contract to the Monad Testnet using the keystore file
forge create src/Counter.sol:Counter --account monad-deployer --broadcast
```
-### Verify your contract on Monad Testnet
+### Verify Contract
```shell
-forge verify-contract --chain-id 10143 --verifier sourcify --verifier-url https://sourcify-api-monad.blockvision.org
+forge verify-contract \
+ \
+ src/Counter.sol:Counter \
+ --chain 10143 \
+ --verifier sourcify \
+ --verifier-url https://sourcify-api-monad.blockvision.org
```
### Cast
-
+[Cast reference](https://book.getfoundry.sh/cast/)
```shell
cast
```
@@ -98,13 +112,13 @@ This error happens when you don't have enough balance to deploy your contract. Y
cast wallet address --account monad-deployer
```
-### I have constructor arguments, how do I deploy my contract?
+### I have constructor arguments, how do I deploy my contract?
```shell
forge create src/Counter.sol:Counter --account monad-deployer --broadcast --constructor-args
```
-### I have constructor arguments, how do I verify my contract?
+### I have constructor arguments, how do I verify my contract?
```shell
forge verify-contract --chain-id 10143 --verifier sourcify --verifier-url https://sourcify-api-monad.blockvision.org --constructor-args
From 23ce129896a6b0746d33b238ffa1ed8c26466ff8 Mon Sep 17 00:00:00 2001
From: Keone Hon
Date: Sun, 2 Mar 2025 18:10:53 -0500
Subject: [PATCH 7/7] trivial - update Counter.sol based on forge fmt
---
src/Counter.sol | 2 +-
test/Counter.t.sol | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/Counter.sol b/src/Counter.sol
index 8cc4c42..aded799 100644
--- a/src/Counter.sol
+++ b/src/Counter.sol
@@ -11,4 +11,4 @@ contract Counter {
function increment() public {
number++;
}
-}
\ No newline at end of file
+}
diff --git a/test/Counter.t.sol b/test/Counter.t.sol
index 831b911..54b724f 100644
--- a/test/Counter.t.sol
+++ b/test/Counter.t.sol
@@ -16,7 +16,7 @@ contract CounterTest is Test {
counter.increment();
assertEq(counter.number(), 1);
}
-
+
function testFuzz_SetNumber(uint256 x) public {
counter.setNumber(x);
assertEq(counter.number(), x);