Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip docs #79

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
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
49 changes: 46 additions & 3 deletions packages/hardhat-forge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@ This Hardhat plugin is for [forge](https://github.com/foundry-rs/foundry/tree/ma

## What

This plugin provides bindings for `forge` commands as hardhat tasks.
This plugin enables projects to use both foundry and hardhat. It provides
bindings for `forge` commands as hardhat tasks. It generates hardhat style
artifacts that can be used with hardhat tooling such as
[hardhat-deploy](https://github.com/wighawag/hardhat-deploy) or hardhat tasks.

It is useful for projects that already have hardhat tooling and want to take
advantage of features only found in foundry such as writing tests in solidity
or fuzzing. It also allows for projects to write tests in solidity and do
chainops in TypeScript or JavaScript.

## Installation

Expand All @@ -28,13 +36,48 @@ import "@foundry-rs/hardhat-forge";

This plugin provides the following tasks:

- "forge::build" for "`forge build`
- "forge::test" for "`forge test`
- `forge:config` returns the forge config
- `compile` overwrites the standard hardhat compile and uses the foundry
toolchain instead

## Usage

The following hardhat task could be used to interact with a contract named
`Contract` that is compiled with the foundry compiler toolchain.

```js
import { task } from "hardhat/config"
import assert from "assert"

task("example").setAction(async (args, hre) => {
const contract = await this.hre.artifacts.readArtifact("Contract");
console.log(contract.abi)

const info = await this.hre.artifacts.getBuildInfo("Contract");
assert(typeof info === "object")
})
```

## Configuration

See [Foundry](https://github.com/foundry-rs/foundry).

The `HardhatUserConfig` is extended with a `foundry` object that can be used
to configure the plugin as well as `forge`. Configuration that is passed in via
the `HardhatUserConfig` will overwrite values that are configured in the
`foundry.toml`.

Note that `forge` must be configured to generate hardhat style build info files
for this plugin to function correctly.

```js
const config: HardhatUserConfig = {
foundry: {
buildInfo: true,
},
}
```

## LICENSE

- MIT license ([LICENSE](LICENSE) or https://opensource.org/licenses/MIT)