#Migrating away from hardhat-waffle
In the past, our recommended setup included Waffle, by using the hardhat-waffle plugin.
However, we now recommend using Hardhat Toolbox, a plugin that bundles a curated set of useful packages. This set includes Hardhat Chai Matchers and Hardhat Network Helpers, which work as an improved replacement for hardhat-waffle.
Migrating to the Toolbox only takes a few minutes. If you do so, you'll get more functionality, like support for Solidity custom errors and native bigint support, and a more reliable testing experience. It will also make it easier for you to keep up to date with our recommended setup.
# Migrating to Hardhat Toolbox
Follow these steps to migrate your project to Hardhat Toolbox.
-
First you'll need to remove some packages from your project.
npm 7+npm 6yarnpnpmnpm uninstall @nomiclabs/hardhat-waffle ethereum-waffle @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan chai@4 ethers hardhat-gas-reporter solidity-coverage @typechain/hardhat typechain @typechain/ethers-v5 @ethersproject/abi @ethersproject/providersnpm uninstall @nomiclabs/hardhat-waffle ethereum-waffle @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan chai@4 ethers hardhat-gas-reporter solidity-coverage @typechain/hardhat typechain @typechain/ethers-v5 @ethersproject/abi @ethersproject/providersyarn remove @nomiclabs/hardhat-waffle ethereum-wafflepnpm remove @nomiclabs/hardhat-waffle ethereum-waffle -
Then you need to install the Toolbox. If you are using yarn or an old version of npm, you'll also have to install some other packages (the peer dependencies of the Toolbox).
npm 7+npm 6yarnpnpmnpm install --save-dev @nomicfoundation/hardhat-toolbox@hh2npm install --save-dev @nomicfoundation/hardhat-toolbox@hh2 @nomicfoundation/hardhat-ignition-ethers@hh2 @nomicfoundation/hardhat-network-helpers@hh2 @nomicfoundation/hardhat-chai-matchers@hh2 @nomicfoundation/hardhat-ethers@hh2 @nomicfoundation/hardhat-verify@hh2 chai@4 ethers hardhat-gas-reporter solidity-coverage @typechain/hardhat typechain @typechain/ethers-v6yarn add --dev @nomicfoundation/hardhat-toolbox@hh2 @nomicfoundation/hardhat-ignition-ethers@hh2 @nomicfoundation/hardhat-network-helpers@hh2 @nomicfoundation/hardhat-chai-matchers@hh2 @nomiclabs/hardhat-ethers@hh2 @nomiclabs/hardhat-etherscan@hh2 chai@4 ethers@5 hardhat-gas-reporter solidity-coverage @typechain/hardhat typechain @typechain/ethers-v6pnpm add -D @nomicfoundation/hardhat-toolbox@hh2 @nomicfoundation/hardhat-network-helpers@hh2 ethers chai@4 -
Finally, remove
hardhat-wafflefrom your imported plugins and import the Toolbox instead:TypeScriptJavaScript- import "@nomiclabs/hardhat-waffle"; + import "@nomicfoundation/hardhat-toolbox";- require("@nomiclabs/hardhat-waffle"); + require("@nomicfoundation/hardhat-toolbox");Adding the Toolbox will make many other imports redundant, so you can remove any of these if you want:
@nomicfoundation/hardhat-ethers@nomicfoundation/hardhat-verify@nomicfoundation/hardhat-ignition@nomicfoundation/hardhat-ignition-ethershardhat-gas-reportersolidity-coverage@typechain/hardhat
Check the Hardhat Chai Matchers and Hardhat Network Helpers docs to learn more about the functionality included in the Toolbox.