Buidler has evolved: Introducing Hardhat
Mainnet forking, support for multiple compiler versions, Etherscan code verification, and crazy-fast compiling
Mainnet forking, support for multiple compiler versions, Etherscan code verification, and crazy-fast compiling
For those of you who don’t know, BuidlerHardhat is a development environment to compile, deploy, test, and debug your Ethereum software.
Introducing 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. While we’ll always have fond memories of the phase of Ethereum evolution the name Buidler represents, the confusing pronunciation and the difficulty to search for it online has been a challenge. The second reason this release is special is that this new release packs a lot of new functionality.
When Buidler was born, back in 2018, the #BUIDL meme was taking off in the Ethereum ecosystem, and it was a side project so we didn’t think through the full implications of the spelling or branding in the long run. Fast-forward to 2020, and Hardhat is no longer a side-project, but a fully-fledged product redefining Ethereum developer experience. It is the tooling backbone of over 1000 Github repositories, including more than 30 top tier teams, amongst which are some of the most advanced protocols driving Ethereum forward like Aave, Synthetix, Balancer, and Optimism.
Given that the rebranding itself breaks backward compatibility, we decided to include all the other breaking changes we’ve been meaning to release for a long time, as well as some of the most highly anticipated features our users have been asking for.
In terms of name changes:
- 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 star development network with
console.log
and stack traces for Solidity, is now called Hardhat Network. - The NPM
@nomiclabs/buidler
package will go into maintenance mode and stop receiving new features. The new package name ishardhat
. - All Nomic Labs plugins will start being published under a
@nomiclabs/hardhat-<plugin>
nomenclature.
Among the many small changes we’ve made, plugins are now easier to install and they won’t work with Hardhat until they’re migrated to the Hardhat plugin API. We kindly ask the community to also republish your updated plugin packages under the hardhat-<plugin>
nomenclature to make compatibility simple to understand for users.
Check out the Buidler to Hardhat project migration guide to upgrade your project.
Mainnet forking on Hardhat Network
A common task for Ethereum developers is to integrate contracts, dapps, or backend services against on-chain protocols that are difficult to deploy and populate with realistic data. Mainnet forking allows Hardhat Network to pull contract deployments and their state from the live mainnet network to use them locally. Besides the network delay when surgically pulling the data that is needed, it’s functionally identical to having a local copy of mainnet running on Hardhat Network, with all the usual debugging utilities we all love.
We took our time to make sure the implementation was up to our standards of quality. We collaborated with EthWorks on building it, and we’re happy that it works reliably and quickly. We recommend running it against Alchemy given that all their plans include archival data, which means you can pin any block number in your config, and Hardhat Network will store the data it pulls in a disk cache, making subsequent runs as fast as a non-forked run. This makes it up to 20x faster than using alternative mainnet forking solutions. Read the mainnet forking guide to learn how to use it.
This has been by far the most highly requested feature, and some of our most loyal users have been waiting for it for a while. It’s happening, Luis!
We’d like to express our gratitude to our friends over at ganache for pioneering this feature.
Revamped compilation pipeline
The Ethereum software development platform has a unique property around compilation due to its immutable nature. Once a contract is deployed, the compiler version that was used to compile that contract is the compiler that will always be used in the future for this contract. This leads to situations where projects have deployments in older Solidity versions to those they’re currently using in development, or sometimes several existing deployments across different versions. This means project setups that need to run several different compilers. Buidler always supported this use case through sheer flexibility by using multiple configuration files, but this approach has significant limitations. This property of Ethereum is not going anywhere and will only become more recurring as years go by, so we decided to take the hard path and completely rebuild Hardhat’s compilation pipeline to accurately match the inherent properties of the platform. Users should now be able to configure any arbitrarily complex compilation setup, down to the individual file level. Read the compilation guide to learn how to set it up.
While doing this we collaborated with the Solidity team to get macOS native binaries of solc distributed for all historical versions, so now Hardhat will by default use the native binaries across all operating systems. Combined with optimizations to aggressively select the most minimal subset of code that can be compiled for the latest code modifications, Hardhat delivers crazy compilation time improvements.
For Synthetix, compiling everything from scratch went down from ~45 seconds to ~7 seconds. Subsequent compilations modifying two files at random take ~2 seconds.
For Kyber, compiling from scratch went down from ~110 seconds to ~39 seconds. Subsequent compilations modifying two files at random take ~12 seconds.
Tenderly integration
Tenderly is an advanced Ethereum monitoring, debugging and data platform. We collaborate with them extensively on all fronts, and their product is an excellent debugging and monitoring tool. This is why we’re excited to announce that they’re launching a plugin for deep integration of Tenderly into the Hardhat workflow! Check out their announcement to learn more.
Etherscan code verification
We released an update to our Etherscan plugin back in September, but I didn’t want to miss the opportunity to mention it again, since it’s such a meaningfully valuable piece of software. The latest release does a lot automatically, as well as simulating the verification process locally to diagnose exactly what’s going wrong. We know first-hand that developers have wasted countless hours dealing with this, but this is no longer necessary. Learn more about it on Github.
Complete list of changes
The list of updates in this release is long (more than 1000 commits went into it!), but the most substantial changes have been listed here. Check out the complete list of what’s new on Github.
New website, Twitter account, and Discord server
It’s time for Hardhat to have its own social media presence, so make sure to follow @HardhatHQ on Twitter to stay up to date on the latest news.
The Telegram support group had gotten too big to be an effective place for technical discussions, so we migrated to a better-organized Discord server.
Finally, we’ve put together a proper website that effectively communicates how Hardhat adds value. Take a look and share it with any Ethereum developer whose soul is hurting.