Hardhat is fast becoming the development environment of choice for many Ethereum developers, thanks to its focus on automation and recurring tasks, as well as its built-in local Ethereum network. In this technical article, we’ll show you how to use Hardhat to build, deploy, and interact with three different types of smart contracts that make use of the Chainlink Network:API Consumer contract that fetches external data Price Feeds Consumer contract that reads the latest price from a Chainlink Price Feed VRF Consumer contract that requests a random number using Chainlink VRF Overview and Prerequisites
Hardhat is a development environment for Ethereum developers that helps manage and automate recurring tasks. Tasks are simple repeatable functions that contain certain metadata, such as what parameters the task requires. An example of a task is funding a deployed contract with some ETH or other token.
Hardhat also comes with its own local development network called the Hardhat Network, which focuses on Solidity debugging and additional logging, as well as giving developers a local development environment that’s ideal for developing and refining code.
A lot of Hardhat’s functionality comes from plugins, which are essentially tasks or external bits of code that are injected into a project. Two popular Hardhat plugins are the web3 and ethers.js plugins, both of which give the developer access to interact with an Ethereum network.
In our source code, we’ve created a ‘Chainlink Hardhat Box’, which is basically a Hardhat project that contains all the tasks and smart contracts needed to implement and deploy the main features offered by the Chainlink Network today in your Solidity smart contracts.
The first step is to download the source code of the Chainlink Hardhat box and install the required dependencies:git clone https://github.com/pappas999/chainlink-hardhat-box cd chainlink-hardhat-box yarn