TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

npm buidler


Buidler plugin for integration with Waffle.


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.


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:



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, so it also injects an ethers object into the BRE, which is documented here.


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

import { deployContract } from "ethereum-waffle";

you should do

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.

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"
  1. 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.

Package Sidebar


npm i @nomiclabs/buidler-waffle

Weekly Downloads






Unpacked Size

35.3 kB

Total Files


Last publish


  • schaable
  • kanej
  • fzeoli
  • alcuadrado
  • fvictorio