Hardhat: An Ethereum Development Environment
A brief breakdown the features I like about the increasingly popular Ethereum development environment, Hardhat
The previous technical newsletters have focused specifically on the Solidity language, but there is more to blockchain development than just the language itself. When you are comfortable with the language it is time to move on to selecting a development environment that will allow you to test and deploy smart contracts.
Development environments are a collection of procedures and tools for developing, testing and dubgging an application or program - techopedia.com
You can think of a development environment like a factory that contains tools to piece together the individual parts (Solidity smart contracts) of a car and then ship it off to run on the road (blockchain). There are multiple Ethereum development environments available today like Truffle (The OG), Hardhat (making a buzz) and scaffold-eth (All-in-one). I encourage you to take a look at the Ethereum development tools page to compare and determine which tool is suitable for you, but for the sake of simplicity and personal preference, I will be using Hardhat. Rather than listing out my reasons, I will link to the newsletter that summarizes how I landed on using Hardhat.
Getting started with Hardhat requires node.js and npm to be installed on your computer. For those new to engineering, I would recommend installing nvm to install both, which is a version management tool that allows you to switch between node versions and includes npm. This is a much simpler tool than installing and maintaining individual versions of node.js and npm separately.
Once you have these languages installed on your computer, you will be able to follow the Hardhat tutorial to install local Hardhat projects and get started with your Solidity project. Rather than regurgitate the Hardhat setup, which is well defined on their website, I will highlight some of the great features of using Hardhat when building, testing, and deploying your Solidity project to the blockchain.
Plugins are a feature that is becoming more common among the development environments, but I think what is unique about Hardhat is that its architecture and infrastructure are built around this composability. They aren’t looking for vendor lock-in and even provide documentation on how you can interact with other 3rd party tools like Truffle’s node environment or Web3.js. Hardhat provides the boilerplate and allows you to build and change whatever you like. No other environment at the moment has this level of flexibility for developers.
CLI and Tasks
So far my newsletter has focused on Solidity and raw deployment/interaction with smart contracts, but what if we wanted to interact with these contracts within a web application? This is where Ethers.js, comes in handy as it is a front-end library that creates a gateway between the browser and the Ethereum blockchain. This library is crucial to create Dapps that allow users to connect and interact with an application via their wallet.
There is a great Discord community that connects you with other users of Hardhat, as well as the creators and maintainers of the open-source software. Outside of Github issues, I can’t think of a better place to get real-time support for your Hardhat issues. In the few instances I have surfaced problems I was facing with my own development, multiple members of the community responded to help out!