github NomicFoundation/hardhat hardhat@2.10.0
Hardhat 2.10.0: A refreshed experience

latest releases: hardhat@2.22.12, hardhat@2.22.11, @nomicfoundation/hardhat-verify@2.0.11...
2 years ago

Hardhat 2.10.0 is out, and it 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 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 setup that is ready to start building Ethereum software out-of-the-box. No 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. Read on to learn more about it.

Hardhat Toolbox

You can get our recommended setup by installing the @nomicfoundation/hardhat-toolbox plugin.

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.

You can learn how to migrate to it here.

Hardhat Chai Matchers

@nomicfoundation/hardhat-chai-matchers is a drop-in replacement of @nomiclabs/hardhat-waffle that integrates more tightly with Hardhat, adds new functionality and improves its error messages. We recommend migrating to it.

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 release our own Chai matchers.

Some of its functionality and improvements:

  • All of hardhat-waffle’s matchers are supported
  • Great support for BigNumber and native bigint
    • No need to think about them anymore
    • Our matchers can compare any combination of
      • number
      • Native bigint
      • ethers.BigNumber
      • BN.js
  • Better revert matchers
    • New matchers for reverted transactions: .revertedWithPanic, .revertedWithCustomError, .revertedWithoutReason
    • .revertedWith matches the exact string, not a substring
  • Better matching of events
    • Fixed a bug where .to.emit("A").and.to.emit("B") was ignoring the first event completely
    • Better matching of event arguments
      • You can ignore some argument and only check the rest
      • You can write an arbitrary predicate for each argument
  • Better error messages
  • Multiple stability improvements

You can learn more about it here.

Hardhat Network Helpers

@nomicfoundation/hardhat-network-helpers is a library that provides a set of utility functions to interact with the Hardhat Network. When using this library you don’t have to deal with low-level JSON-RPC calls. No more encoding parameters in hexadecimal nor hard to understand Hardhat Network errors.

It includes utilities for time manipulation, modify contracts and accounts, manipulate the mempool, reuse common testing setups using fixtures, and more.

Using the helpers is as simple as this:

// before: mine 100 blocks
await network.provider.send("hardhat_mine", ["0x64"]);

// now
const helpers = require("@nomicfoundation/hardhat-network-helpers");
await helpers.mine(100);

You can learn more about it here.

@nomiclabs/hardhat-ethers

Our @nomiclabs/hardhat-ethers has a new helper that makes impersonating accounts easier. Now you can do:

const signer = await hre.ethers.getImpersonatedSigner("0x1234567890123456789012345678901234567890");
console.log(await signer.getBalance());

Other Hardhat changes

  • Add support for Node 18
  • Upgrade Mocha to 10.x
  • Upgrade ethereum-cryptography to 1.x (Thanks @paulmillr!)
  • Removed a workaround to past Ganache's gas estimation problems (Thanks @JuanuMusic!)
  • Drop support for Node 12

Don't miss a new hardhat release

NewReleases is sending notifications on new releases.