github NomicFoundation/hardhat hardhat-v2.0.0
Buidler is now Hardhat 👷‍♂️

latest releases: hardhat@2.22.4, @nomiclabs/hardhat-solhint@3.1.0, @nomicfoundation/hardhat-viem@2.0.2...
3 years ago

We are pleased to announce the release of Hardhat, the new and evolved version of Buidler. This release is a special one for two reasons. Naturally, the first is due to the rebrand. The second reason this release is special is that this new release packs a lot of new functionality.

You can learn more about this release in our announcement. Check out our Migrating from Buidler guide to learn how to start using it in your existing projects, or the Getting started guide to try it out in a fresh project.

Changelog

This is the complete list of changes introduced in Hardhat.

Rebranded the different components

  • Buidler, as a development environment, is now called Hardhat.
  • The task runner component, used to extend and customize setups, is now called Hardhat Runner.
  • Buidler EVM, our development network with console.log and stack traces for Solidity, is now called Hardhat Network.

Package names and versions

  • The @nomiclabs/buidler package is now hardhat.
  • The official Buidler plugins, which used to have package names like @nomiclabs/buidler-<plugin> are now named @nomiclabs/hardhat-<plugin>.
  • All package versions start from 2.0.0. The only exceptions are @nomiclabs/hardhat-ethers and @nomiclabs/hardhat-waffle.
    • Use their 2.0.0 version if you want to use ethers.js v5.
    • Use their 1.0.0 version if you want to use ethers.js v4.

Mainnet forking on Hardhat Network

Hardhat Network can now fork from Mainnet and other live networks, replicating their state without having to sync an entire blockchain. Read the guide to learn how to use it.

Revamped compilation pipeline

Hardhat has a new Solidity compilation pipeline. This includes lots of improvements:

  • Native support for multiple Solidity versions in a single project. Check out the compiling your contracts guide to learn how to set it up.
  • Smarter caching and recompilation, leading to dramatically faster builds
  • Hardhat uses native versions of solc whenever possible, relying on solcjs only as a fallback.
  • You can now customize any setting of solc, not just the optimizer.

Improved ethers.js support

Hardhat comes with better support from ethers.js:

  • The @nomiclabs/hardhat-ethers now offers a native way of linking libraries.
  • The signers returned by ethers.getSigners() have an address property now. No more await signer.getAddress() everywhere.

Both versions of the plugin have received the same improvements. Please, refer to their documentation to learn more.

Improved TypeScript support

Setting up TypeScript in Hardhat is now simpler. All you need to do is install typescript, ts-node and have a hardhat.config.ts that imports your plugins.

There's no need to have a tsconfig.json with special settings. Check our TypeScript guide to learn more.

Other improvements

Hardhat's core

  • Global installations of Hardhat cannot be used anymore, except for initializing a project.
  • The function usePlugin doesn't exist anymore. Plugins are automatically loaded when imported/required.
  • Hardhat supports having multiple contracts with the same name.
  • When reading an artifact, an error will be thrown if there are multiple contracts with the same name (link).
  • The artifacts directory stores artifacts in a nested structure, and it has new files (link).
  • The readArtifact and readArtifactSync functions from hardhat/plugins don't exist anymore. Instead, the hre has an artifacts object to interact with artifacts (link).
  • internalTask is deprecated. Users should use subtask now.
  • The default solc used is now 0.7.3.
  • When configuring accounts, private keys are automatically 0x prefixed when appropriate.
  • type-extensions.d.ts and plugin entries in tsconfig.json#files are no longer needed
  • All the TypeScript types now live under hardhat/types. You shouldn't use deeper modules like hardhat/types/config, unless you are extending an interface.
  • The solc input/output jsons are no longer saved in the cache directory.
  • Hardhat providers are now compatible with EIP1193.
  • The project setup creates a package.json and (optionally) installs the needed dependencies.
  • subtask supports complex types, no need to use stringified objects anymore.
  • Solidity imports and artifacts names are case sensitive now.
  • The hre global variable is now present when running scripts, tests, and tasks.
  • Files can be imported from node_modules using relative paths.
  • There's a new solidity-files-cache.json file in the cache. This file is considered internal and shouldn't be depended upon nor modified.
  • Hardhat collects anonymous data if the user gives its consent.
  • If --network isn't used, the value of args.network is undefined instead of having the value of the default network.
  • tsconfig is now a reserved param (not used at the moment)

Hardhat Network

  • Hardhat Network accounts now can be configured using a mnemonic.
  • Hardhat Network has new RPC methods: hardhat_impersonateAccount, hardhat_stopImpersonatingAccount and hardhat_reset.
  • The value returned by the Hardhat Network for the web3_clientVersion method is now a Hardhat-specific value.
  • Hardhat Network's eth_getStorageAt method now always returns 32 bytes.

Builtin tasks

  • The flatten task can receive a list of files to be flattened.
  • The compile task has a new --quiet flag.
  • The subtasks of the compile task were significantly changed. This can affect you if you were overriding some of them.
  • Better error messages when solc returns an internal compiler error.
  • The clean task has a --global flag, which deletes the Solidity compilers and other global caches.
  • The default hostname of hardhat node is 0.0.0.0 when executed inside a docker container.

Hardhat ether.js plugins

  • hardhat-ethers: contract factories for abstract contracts cannot be created anymore. Use getContractAt if you want to use an abstract interface to interact with a deployed contract.

Don't miss a new hardhat release

NewReleases is sending notifications on new releases.