Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: test
name: CI

on: workflow_dispatch
on:
push:
pull_request:
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci
Expand All @@ -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

Expand Down
110 changes: 51 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,88 +1,79 @@
## Foundry-Monad
## 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`
> [!NOTE]
> In this Foundry template, the default chain is `monadTestnet`, If you wish to change it, change the network in `foundry.toml`

<h4 align="center">
<a href="https://docs.monad.xyz">Monad Documentation</a> | <a href="https://book.getfoundry.sh/">Foundry Documentation</a> |
<a href="https://docs.monad.xyz">Monad Documentation</a> | <a href="https://book.getfoundry.sh/">Foundry Documentation</a> |
<a href="https://github.com/monad-developers/foundry-monad/issues">Report Issue</a>
</h4>

_Foundry-Monad is a Foundry template with Monad configuration. So developers don't have to do the initial configuration in Foundry for Monad network._

**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.

## Requirements
## Documentation

Before you begin, you need to install the following tools:
https://book.getfoundry.sh/

- Rust
- Cargo
- [Foundryup](https://book.getfoundry.sh/getting-started/installation)
## Usage

## Quickstart

To get started, follow the steps below:

1. You can either clone this repo using the below command:
### Build

```sh
git clone https://github.com/monad-developers/foundry-monad
```shell
forge build
```

or

You can do it manually using the below set of commands:
### Test

```sh
mkdir [project_name] && cd [project_name] && forge init --template monad-developers/foundry-monad
```shell
forge test
```

The foundry project is now ready to be used!
### Format

## Examples
```shell
forge fmt
```

### Compile
### Gas Snapshots

```shell
forge compile
forge snapshot
```

### Build
### Anvil

```shell
forge build
anvil
```

### Test
### 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 test
cast wallet import monad-deployer --private-key $(cast wallet new | grep 'Private key:' | awk '{print $3}')
```

### Deploy and Verify
After creating the keystore, you can read its address using:

```shell
forge create \
--private-key <your_private_key> \
src/Counter.sol:Counter \
--broadcast \
--verify \
--verifier sourcify \
--verifier-url https://sourcify-api-monad.blockvision.org
cast wallet address --account monad-deployer
```

### Deploy
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 create --private-key <your_private_key> src/Counter.sol:Counter --broadcast
forge create src/Counter.sol:Counter --account monad-deployer --broadcast
```

### Verify Contract
Expand All @@ -96,40 +87,41 @@ forge verify-contract \
--verifier-url https://sourcify-api-monad.blockvision.org
```

### Format

### Cast
[Cast reference](https://book.getfoundry.sh/cast/)
```shell
forge fmt
cast <subcommand>
```

### Gas Snapshots
### Help

```shell
forge snapshot
forge --help
anvil --help
cast --help
```

### Anvil

```shell
anvil
```
## FAQ

### Cast
### 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
cast <subcommand>
cast wallet address --account monad-deployer
```

### Help
### I have constructor arguments, how do I deploy my contract?

```shell
forge --help
forge create src/Counter.sol:Counter --account monad-deployer --broadcast --constructor-args <constructor_arguments>
```

```shell
anvil --help
```
### I have constructor arguments, how do I verify my contract?

```shell
cast --help
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>
```

Please refer to the [Foundry Book](https://book.getfoundry.sh/) for more information.
2 changes: 1 addition & 1 deletion src/Counter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ contract Counter {
function increment() public {
number++;
}
}
}
2 changes: 1 addition & 1 deletion test/Counter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading