1- ## Foundry- Monad
1+ ## Monad-flavored Foundry
22
3- > [ !NOTE]
4- > In this foundry template the default chain is ` monadTestnet ` , if you wish to change it change the network in ` foundry.toml `
3+ > [ !NOTE]
4+ > In this Foundry template, the default chain is ` monadTestnet ` , If you wish to change it, change the network in ` foundry.toml `
55
66<h4 align =" center " >
7- <a href =" https://docs.monad.xyz " >Monad Documentation</a > | <a href =" https://book.getfoundry.sh/ " >Foundry Documentation</a > |
7+ <a href =" https://docs.monad.xyz " >Monad Documentation</a > | <a href =" https://book.getfoundry.sh/ " >Foundry Documentation</a > |
88 <a href =" https://github.com/monad-developers/foundry-monad/issues " >Report Issue</a >
99</h4 >
1010
11- _ Foundry-Monad is a Foundry template with Monad configuration. So developers don't have to do the initial configuration in Foundry for Monad network._
1211
1312** Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
1413
1514Foundry consists of:
1615
17- - ** Forge** : Ethereum testing framework (like Truffle, Hardhat and DappTools).
18- - ** Cast** : Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
16+ - ** Forge** : Ethereum testing framework (like Truffle, Hardhat, and DappTools).
17+ - ** Cast** : Swiss army knife for interacting with EVM smart contracts, sending transactions, and getting chain data.
1918- ** Anvil** : Local Ethereum node, akin to Ganache, Hardhat Network.
2019- ** Chisel** : Fast, utilitarian, and verbose solidity REPL.
2120
22- ## Requirements
21+ ## Documentation
2322
24- Before you begin, you need to install the following tools:
23+ https://book.getfoundry.sh/
2524
26- - Rust
27- - Cargo
28- - [ Foundryup] ( https://book.getfoundry.sh/getting-started/installation )
25+ ## Usage
2926
30- ## Quickstart
31-
32- To get started, follow the steps below:
33-
34- 1 . You can either clone this repo using the below command:
27+ ### Build
3528
36- ``` sh
37- git clone https://github.com/monad-developers/foundry-monad
29+ ``` shell
30+ forge build
3831```
3932
40- or
41-
42- You can do it manually using the below set of commands:
33+ ### Test
4334
44- ``` sh
45- mkdir [project_name] && cd [project_name] && forge init --template monad-developers/foundry-monad
35+ ``` shell
36+ forge test
4637```
4738
48- The foundry project is now ready to be used!
39+ ### Format
4940
50- ## Examples
41+ ``` shell
42+ forge fmt
43+ ```
5144
52- ### Compile
45+ ### Gas Snapshots
5346
5447``` shell
55- forge compile
48+ forge snapshot
5649```
5750
58- ### Build
51+ ### Anvil
5952
6053``` shell
61- forge build
54+ anvil
6255```
6356
64- ### Test
57+ ### Deploy to Monad Testnet
58+
59+ First, you need to create a keystore file. Do not forget to remember the password! You will need it to deploy your contract.
6560
6661``` shell
67- forge test
62+ cast wallet import monad-deployer --private-key $( cast wallet new | grep ' Private key: ' | awk ' {print $3} ' )
6863```
6964
70- ### Deploy and Verify
65+ After creating the keystore, you can read its address using:
7166
7267``` shell
73- forge create \
74- --private-key < your_private_key> \
75- src/Counter.sol:Counter \
76- --broadcast \
77- --verify \
78- --verifier sourcify \
79- --verifier-url https://sourcify-api-monad.blockvision.org
68+ cast wallet address --account monad-deployer
8069```
8170
82- ### Deploy
71+ The command above will create a keystore file named ` monad-deployer ` in the ` ~/.foundry/keystores ` directory.
72+
73+ Then, you can deploy your contract to the Monad Testnet using the keystore file you created.
8374
8475``` shell
85- forge create --private-key < your_private_key > src/Counter.sol:Counter --broadcast
76+ forge create src/Counter.sol:Counter --account monad-deployer --broadcast
8677```
8778
8879### Verify Contract
@@ -96,40 +87,41 @@ forge verify-contract \
9687 --verifier-url https://sourcify-api-monad.blockvision.org
9788```
9889
99- ### Format
100-
90+ ### Cast
91+ [ Cast reference ] ( https://book.getfoundry.sh/cast/ )
10192``` shell
102- forge fmt
93+ cast < subcommand >
10394```
10495
105- ### Gas Snapshots
96+ ### Help
10697
10798``` shell
108- forge snapshot
99+ forge --help
100+ anvil --help
101+ cast --help
109102```
110103
111- ### Anvil
112104
113- ``` shell
114- anvil
115- ```
105+ ## FAQ
116106
117- ### Cast
107+ ### Error: ` Error: server returned an error response: error code -32603: Signer had insufficient balance `
108+
109+ This error happens when you don't have enough balance to deploy your contract. You can check your balance with the following command:
118110
119111``` shell
120- cast < subcommand >
112+ cast wallet address --account monad-deployer
121113```
122114
123- ### Help
115+ ### I have constructor arguments, how do I deploy my contract?
124116
125117``` shell
126- forge --help
118+ forge create src/Counter.sol:Counter --account monad-deployer --broadcast --constructor-args < constructor_arguments >
127119```
128120
129- ``` shell
130- anvil --help
131- ```
121+ ### I have constructor arguments, how do I verify my contract?
132122
133123``` shell
134- cast --help
124+ forge verify-contract < contract_address > < contract_name > --chain-id 10143 --verifier sourcify --verifier-url https://sourcify-api-monad.blockvision.org --constructor-args < abi_encoded_constructor_arguments >
135125```
126+
127+ Please refer to the [ Foundry Book] ( https://book.getfoundry.sh/ ) for more information.
0 commit comments