Hardhat 2.10.0: A refreshed experience
This release marks a change in the product direction that Hardhat has historically taken. Hardhat’s core values have always been…
This release marks a change in the product direction that Hardhat has historically taken. Hardhat’s core values have always been optionality, flexibility, and extensibility, enabling it to be used in whatever ways were needed and found to be useful. However, as we described in this Twitter thread, the Ethereum and Hardhat development ecosystems grew too large for easy navigation among the many different paths and viable options. While retaining those core values, Hardhat 2.10.0 now offers a complete and opinionated experience that is ready to start building Ethereum software out-of-the-box — no need to make any decisions on plugins, libraries, or dependencies. Just get going.
We’re calling this the Hardhat Toolbox, which is a bundle of plugins and functionality that the Nomic Foundation team considers to be the best way to get started with a new Ethereum project.
There’s no breaking of backward compatibility, and no requirement to use Hardhat Toolbox. Everything remains as flexible and optional as always, but getting started is now a much better experience.
Migrating from a classic unbundled Hardhat setup, where each component is individually chosen and set up, to the simpler bundled Hardhat Toolbox setup, should only take a few minutes. We recommend doing so if you’re already using the same components.
This new, simpler, and opinionated path also means less boilerplate. This is what a basic config file using Hardhat Toolbox looks like:
This is enough to:
- Deploy and interact with your contracts using ethers.js and the hardhat-ethers plugin.
- Test your contracts with Mocha, Chai, and our new Hardhat Chai Matchers plugin.
- Interact with Hardhat Network with our new 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 test coverage with solidity-coverage.
- Get type bindings for your contracts with Typechain, if you are using TypeScript.
We will continue to improve this bundle of functionality with future releases. This means that we’ll have the ability to add new plugins that deserve to be part of the default Hardhat experience into Hardhat Toolbox, which wasn’t something that we could do before, since plugins have always been opt-in. This represents a major improvement in easy delivery of new functionality for users.
The new Hardhat Chai Matchers plugin
With Hardhat 2.10.0, we’re taking advantage of this new delivery channel by releasing a new drop-in replacement for hardhat-waffle. Since the very beginning, we’ve recommended that people use Waffle, via hardhat-waffle, and we thank the team at TrueFi for their great work. However, for such a core component of the setup, there were too many recurring issues related to not being integrated deeply enough with Hardhat. For this reason, we decided to fork Waffle, and, through a tighter integration, we added a lot of functionality and improved its error messages.
The new @nomicfoundation/hardhat-chai-matchers
plugin is a drop-in replacement for @nomiclabs/hardhat-waffle
. We recommend migrating to it. To learn more about it check out this section of the documentation.
Lighter and easier
Using Hardhat 2.10.0, you’ll also have fewer dependencies. The new TypeScript sample project has 57% fewer dependencies versus the previous unbundled version.
Installing and hitting the ground running with Hardhat Toolbox is also simpler, as there are just two NPM packages that need to be installed (when using NPM 7+) to get all of the functionality mentioned above:
$ npm install hardhat @nomicfoundation/hardhat-toolbox
A better interface for Hardhat’s JSON-RPC methods
Hardhat Toolbox also comes with the new Hardhat Network Helpers, which make low-level interactions with Hardhat’s custom JSON-RPC methods largely a thing of the past. What used to be:
Now is:
New documentation architecture
We’ve revamped our documentation site to reflect this new direction, revisiting every section and every guide, and writing new ones to migrate most content towards Hardhat Toolbox. It’s also now separated by component in order to manage the growth in the documentation.
Hardhat for Visual Studio Code is out of beta
With this release, we’re also publishing the first stable version of Hardhat for Visual Studio Code, our VSCode extension that adds language support for Solidity and provides editor integration for Hardhat projects. It now shows inline compilation errors up to 50 times faster than previous releases. Give it a try.
Full list of changes
To see everything involved in this new version, check out the release notes, and take the new Hardhat out for a spin!