#Hardhat Toolbox
The @nomicfoundation/hardhat-toolbox
plugin bundles all the commonly used packages and Hardhat plugins we recommend to start developing with Hardhat.
When you use this plugin, you'll be able to:
- Deploy and interact with your contracts using ethers.js and the
hardhat-ethers
plugin. - Test your contracts with Mocha, Chai and our own Hardhat Chai Matchers plugin.
- Interact with Hardhat Network with our Hardhat Network Helpers.
- Verify the source code of your contracts with the hardhat-etherscan plugin.
- Get metrics on the gas used by your contracts with the hardhat-gas-reporter plugin.
- Measure your tests coverage with solidity-coverage.
- And, if you are using TypeScript, get type bindings for your contracts with Typechain.
#Installation
We recommend using npm 7 or later. If you do that, then you just need to install the plugin itself:
npm install --save-dev @nomicfoundation/hardhat-toolbox
If you are using an older version of npm, you'll also need to install all the packages used by the toolbox.
npm install --save-dev @nomicfoundation/hardhat-toolbox @nomicfoundation/hardhat-network-helpers @nomicfoundation/hardhat-chai-matchers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan chai ethers hardhat-gas-reporter solidity-coverage @typechain/hardhat typechain @typechain/ethers-v5 @ethersproject/abi @ethersproject/providers
That's also the case if you are using yarn:
yarn add --dev @nomicfoundation/hardhat-toolbox @nomicfoundation/hardhat-network-helpers @nomicfoundation/hardhat-chai-matchers @nomiclabs/hardhat-ethers @nomiclabs/hardhat-etherscan chai ethers hardhat-gas-reporter solidity-coverage @typechain/hardhat typechain @typechain/ethers-v5 @ethersproject/abi @ethersproject/providers
#Migrating to Hardhat Toolbox
Migrating an existing project to the Toolbox is easy:
-
First, if you are using
hardhat-waffle
, we recommend you migrate to our Hardhat Chai Matchers. They are a drop-in replacement, so this should only take a few minutes. Learn how to do that here. -
Install the toolbox and its dependencies. If you are using npm 7 or later, you just need to do
npm install --save-dev @nomicfoundation/hardhat-toolbox
. If not, check the Installation section above. -
Uninstall
@nomiclabs/hardhat-waffle
andethereum-waffle
, and remove the@nomiclabs/hardhat-waffle
import from your Hardhat config. -
Import the Toolbox in your Hardhat config. This will make many other imports redundant, so you can remove any of these if you want:
@nomiclabs/hardhat-ethers
@nomiclabs/hardhat-etherscan
hardhat-gas-reporter
solidity-coverage
@typechain/hardhat