Using Web3 With Hardhat
Introduction
Following the recent compatibility update of Hardhat plugin hardhat-web3-v4, Web3.Js
is now available to use as plugin in Hardhat.
This tutorial will guide you through using Web3js as a plugin to interact with the Blockchain.
info
This tutorial explains how to create a Web3.js + Hardhat project from scratch. The create-hardhat-web3
command line utility was created to automate many of the steps in this tutorial and make it easier to quickly bootstrap a new Web3.js + Hardhat project.
Pre-requisite
This tutorial assumes you have previous knowledge of writing Smart contracts, and are convenient working with JavaScript/TypeScript. You should have NodeJS version greater than v16 installed.
note
To install dependencies, we will use NPM
.
Steps
- Initiate a Hardhat project
- Install required dependencies (including
hardhat-web3-v4
) - Write the Smart Contract
- Compile and deploying the contract
- Testing and interacting with the contract