Skip to content

Commit ebe4923

Browse files
chore: replace hardhat to foundry
1 parent f5dcffd commit ebe4923

85 files changed

Lines changed: 29283 additions & 3158 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
pull_request:
9+
workflow_dispatch:
10+
11+
env:
12+
FOUNDRY_PROFILE: ci
13+
14+
jobs:
15+
check:
16+
name: Foundry project
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v5
20+
with:
21+
persist-credentials: false
22+
submodules: recursive
23+
24+
- name: Install Foundry
25+
uses: foundry-rs/foundry-toolchain@v1
26+
27+
- name: Show Forge version
28+
run: forge --version
29+
30+
- name: Run Forge fmt
31+
run: forge fmt --check
32+
33+
- name: Run Forge build
34+
run: forge build --sizes
35+
36+
- name: Run Forge tests
37+
run: forge test -vvv

.gitignore

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
1-
# Node modules
2-
/node_modules
1+
# Compiler files
2+
cache/
3+
out/
34

4-
# Compilation output
5-
/dist
5+
# Ignores development broadcast logs
6+
!/broadcast
7+
/broadcast/*/31337/
8+
/broadcast/**/dry-run/
69

7-
# pnpm deploy output
8-
/bundle
10+
# Docs
11+
docs/
912

10-
# Hardhat Build Artifacts
11-
/artifacts
12-
13-
# Hardhat compilation (v2) support directory
14-
/cache
15-
16-
# Typechain output
17-
/types
18-
19-
# Hardhat coverage reports
20-
/coverage
13+
# Dotenv file
14+
.env

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/forge-std"]
2+
path = lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,66 @@
1-
# Sample Hardhat 3 Beta Project (`node:test` and `viem`)
1+
## Foundry
22

3-
This project showcases a Hardhat 3 Beta project using the native Node.js test runner (`node:test`) and the `viem` library for Ethereum interactions.
3+
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
44

5-
To learn more about the Hardhat 3 Beta, please visit the [Getting Started guide](https://hardhat.org/docs/getting-started#getting-started-with-hardhat-3). To share your feedback, join our [Hardhat 3 Beta](https://hardhat.org/hardhat3-beta-telegram-group) Telegram group or [open an issue](https://github.com/NomicFoundation/hardhat/issues/new) in our GitHub issue tracker.
5+
Foundry consists of:
66

7-
## Project Overview
7+
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
8+
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
9+
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
10+
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
811

9-
This example project includes:
12+
## Documentation
1013

11-
- A simple Hardhat configuration file.
12-
- Foundry-compatible Solidity unit tests.
13-
- TypeScript integration tests using [`node:test`](nodejs.org/api/test.html), the new Node.js native test runner, and [`viem`](https://viem.sh/).
14-
- Examples demonstrating how to connect to different types of networks, including locally simulating OP mainnet.
14+
https://book.getfoundry.sh/
1515

1616
## Usage
1717

18-
### Running Tests
18+
### Build
1919

20-
To run all the tests in the project, execute the following command:
20+
```shell
21+
$ forge build
22+
```
23+
24+
### Test
2125

2226
```shell
23-
npx hardhat test
27+
$ forge test
2428
```
2529

26-
You can also selectively run the Solidity or `node:test` tests:
30+
### Format
2731

2832
```shell
29-
npx hardhat test solidity
30-
npx hardhat test nodejs
33+
$ forge fmt
3134
```
3235

33-
### Make a deployment to Sepolia
36+
### Gas Snapshots
3437

35-
This project includes an example Ignition module to deploy the contract. You can deploy this module to a locally simulated chain or to Sepolia.
38+
```shell
39+
$ forge snapshot
40+
```
3641

37-
To run the deployment to a local chain:
42+
### Anvil
3843

3944
```shell
40-
npx hardhat ignition deploy ignition/modules/Counter.ts
45+
$ anvil
4146
```
4247

43-
To run the deployment to Sepolia, you need an account with funds to send the transaction. The provided Hardhat configuration includes a Configuration Variable called `SEPOLIA_PRIVATE_KEY`, which you can use to set the private key of the account you want to use.
48+
### Deploy
4449

45-
You can set the `SEPOLIA_PRIVATE_KEY` variable using the `hardhat-keystore` plugin or by setting it as an environment variable.
50+
```shell
51+
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
52+
```
4653

47-
To set the `SEPOLIA_PRIVATE_KEY` config variable using `hardhat-keystore`:
54+
### Cast
4855

4956
```shell
50-
npx hardhat keystore set SEPOLIA_PRIVATE_KEY
57+
$ cast <subcommand>
5158
```
5259

53-
After setting the variable, you can run the deployment with the Sepolia network:
60+
### Help
5461

5562
```shell
56-
npx hardhat ignition deploy --network sepolia ignition/modules/Counter.ts
63+
$ forge --help
64+
$ anvil --help
65+
$ cast --help
5766
```

foundry.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"lib/forge-std": {
3+
"tag": {
4+
"name": "v1.11.0",
5+
"rev": "8e40513d678f392f398620b3ef2b418648b33e89"
6+
}
7+
}
8+
}

foundry.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[profile.default]
2+
src = "src"
3+
out = "out"
4+
libs = ["lib"]
5+
6+
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

hardhat.config.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

ignition/modules/Counter.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/forge-std/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/Vm.sol linguist-generated

0 commit comments

Comments
 (0)