# @nomiclabs/hardhat-waffle

> Hardhat plugin to test smart contracts with Waffle

Latest version **2.0.6** (published 2023-05-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @nomiclabs/hardhat-waffle
pnpm add @nomiclabs/hardhat-waffle
yarn add @nomiclabs/hardhat-waffle
bun add @nomiclabs/hardhat-waffle
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.6 |
| Published | 2023-05-16 |
| First published | 2020-10-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 48.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Nomic Labs LLC |
| Maintainers | geneaum, fzeoli, alcuadrado, fvictorio |
| Keywords | ethereum, smart-contracts, hardhat, hardhat-plugin, ethers.js |

## Links

- npm: https://www.npmjs.com/package/@nomiclabs/hardhat-waffle
- Repository: https://github.com/NomicFoundation/hardhat-waffle
- Issues: https://github.com/NomicFoundation/hardhat-waffle/issues
- npm.io page: https://npm.io/package/@nomiclabs/hardhat-waffle

## Recent versions

- 2.0.6 (latest) — 2023-05-16
- 2.0.0-rc.1 (rc) — 2020-10-21
- 2.0.5 — 2023-02-10
- 2.0.4 — 2023-02-09
- 2.0.3 — 2022-03-01
- 2.0.2 — 2022-01-19
- 2.0.1 — 2020-12-01
- 1.0.0 — 2020-10-22
- 2.0.0 — 2020-10-22
- 2.0.0-rc.0 — 2020-10-19

## README

[![npm](https://img.shields.io/npm/v/@nomiclabs/hardhat-waffle.svg)](https://www.npmjs.com/package/@nomiclabs/hardhat-waffle) [![hardhat](https://hardhat.org/buidler-plugin-badge.svg?1)](https://hardhat.org)

# hardhat-waffle

[Hardhat](https://hardhat.org) plugin for integration with [Waffle](https://getwaffle.io/).

## What

You can use this plugin to build smart contract tests using Waffle in Hardhat, taking advantage of both.

This plugin adds a Hardhat-ready version of Waffle to the Hardhat Runtime Environment, and automatically initializes the [Waffle Chai matchers](https://ethereum-waffle.readthedocs.io/en/latest/matchers.html).

## Installation

```bash
npm install --save-dev @nomiclabs/hardhat-waffle 'ethereum-waffle@^3.0.0' @nomiclabs/hardhat-ethers 'ethers@^5.0.0' @types/sinon-chai@^3.2.3
```

And add the following statement to your `hardhat.config.js`:

```js
require("@nomiclabs/hardhat-waffle");
```

Or, if you are using TypeScript, add this to your `hardhat.config.ts`:

```js
import "@nomiclabs/hardhat-waffle";
```

## Tasks

This plugin creates no additional tasks.

## Environment extensions

This plugin adds a `waffle` object to the Hardhat Runtime Environment. This object has all the Waffle functionality, already adapted to work with Hardhat.

The `waffle` object has these properties:

- `provider`
- `deployContract`
- `solidity`
- `link`
- `deployMockContract`
- `createFixtureLoader`
- `loadFixture`

This plugin depends on [`@nomiclabs/hardhat-ethers`](https://github.com/nomiclabs/hardhat/tree/master/packages/hardhat-ethers), so it also injects an `ethers` object into the HRE, which is documented [here](https://github.com/nomiclabs/hardhat/tree/master/packages/hardhat-ethers#environment-extensions).

## Usage

Once installed, you can build your tests almost like in Waffle.

Instead of importing things from `ethereum-waffle`, you access them from the `waffle` property of the Hardhat Runtime Environment.

For example, instead of doing

```js
const { deployContract } = require("ethereum-waffle");
```

you should do

```typescript
const { waffle } = require("hardhat");
const { deployContract } = waffle;
```

Also, you don't need to call `chai.use` in order to use [Waffle's Chai matchers](https://ethereum-waffle.readthedocs.io/en/latest/matchers.html).

Note that by default, Hardhat saves its compilation output into `artifacts/` instead of `build/`. You can either use that directory in your tests, or [customize your Hardhat config](https://hardhat.org/hardhat-runner/docs/config#path-configuration).

---
_Source: https://npm.io/package/@nomiclabs/hardhat-waffle · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
