# @nomiclabs/buidler-waffle

> Buidler plugin to test smart contracts with Waffle

Latest version **2.1.0** (published 2020-09-02) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2020-09-02 |
| First published | 2020-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 34.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8505 |
| Author | Nomic Labs LLC |
| Maintainers | alcuadrado, fvictorio, fzeoli |
| Keywords | ethereum, smart-contracts, buidler, buidler-plugin, ethers.js |

## Links

- npm: https://www.npmjs.com/package/@nomiclabs/buidler-waffle
- Repository: https://github.com/nomiclabs/buidler
- Homepage: https://github.com/nomiclabs/buidler/tree/master/packages/buidler-waffle
- Issues: https://github.com/nomiclabs/buidler/issues
- npm.io page: https://npm.io/package/@nomiclabs/buidler-waffle

## Dependencies (2)

- [@types/web3](https://npm.io/package/@types/web3.md) 1.0.19
- [@types/sinon-chai](https://npm.io/package/@types/sinon-chai.md) ^3.2.3

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 2.1.0 (latest) — 2020-09-02
- 1.3.4-rc.0 (rc) — 2020-05-25
- 2.0.0-alpha.1 (next) — 2020-05-10
- 2.0.0 — 2020-06-24
- 1.3.5 — 2020-06-18
- 1.3.4 — 2020-05-28
- 1.3.3 — 2020-05-10
- 1.3.3-rc.0 — 2020-05-05
- 1.3.2 — 2020-05-02
- 2.0.0-alpha.0 — 2020-04-28
- 1.3.1 — 2020-04-28
- 1.3.0 — 2020-04-18
- 1.3.0-rc.1 — 2020-04-10
- 1.3.0-rc.0 — 2020-04-06
- 1.2.0 — 2020-02-27
- … 8 more at https://npm.io/package/@nomiclabs/buidler-waffle/versions

## README

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

# buidler-waffle

[Buidler](http://getbuidler.com) plugin for integration with [Waffle](https://getwaffle.io/).

## What

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

This plugin adds a Buidler-ready version of Waffle to the Buidler 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/buidler-waffle 'ethereum-waffle@^3.0.0' @nomiclabs/buidler-ethers 'ethers@^5.0.0'
```

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

```js
usePlugin("@nomiclabs/buidler-waffle");
```

## Tasks

This plugin creates no additional tasks.

## Environment extensions

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

The `waffle` object has these properties:

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

This plugin depends on [`@nomiclabs/buidler-ethers`](https://github.com/nomiclabs/buidler/tree/master/packages/buidler-ethers),
so it also injects an `ethers` object into the BRE, which is documented [here](https://github.com/nomiclabs/buidler/tree/master/packages/buidler-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 Buidler Runtime Environment.

For example, instead of doing

```typescript
import { deployContract } from "ethereum-waffle";
```

you should do

```typescript
import { waffle } from "@nomiclabs/buidler";
const { deployContract } = waffle;
```

Also, you don't need to call `chai.use`.

Note that by default, Buidler save its compilation output into `artifacts/` instead of `build/`. You can either use
that directory in your tests, or [customize your Buidler config](https://buidler.dev/config/#path-configuration).

## TypeScript support

This plugin supports TypeScript by following these steps:

1. Add these to your `tsconfig.json`'s `files` array:
  * `"node_modules/@nomiclabs/buidler-ethers/src/type-extensions.d.ts"`
  * `"node_modules/@nomiclabs/buidler-waffle/src/type-extensions.d.ts"`

2. Install these packages: `npm install --save-dev @types/mocha @types/chai`

We also recommend enabling `resolveJsonModule` in your `tsconfig.json`, as it's common
to import JSON files directly when using Waffle.

There's no need to import the Waffle's `solidity` Chai matchers. They are
automatically imported and initialized by this plugin, including its types.

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