Skip to main content

Setting up environment

Using hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software. It helps developers manage and automate the recurring tasks that are inherent to the process of building smart contracts and dApps, as well as easily introducing more functionality around this workflow. This guide shows you how to set up a Hardhat project and how to compile, deploy, and test a smart contract.

Install Hardhat

Create a HardHat project using hardhat command

npx hardhat
$

After creating the project, you will see the following files and folders:

test/
├─ scripts/
├─ contracts/
├─ hardhat.config.ts
├─ package.json
├─ tsconfig.json
├─ .env
├─ test/
  • contracts/ folder contains the smart contracts
  • test/ folder contains the test scripts
  • hardhat.config.ts is the configuration file for Hardhat
  • package.json is the npm package file
  • tsconfig.json is the TypeScript configuration file
  • .env is the environment file
  • scripts/ folder contains the scripts to deploy the smart contracts

Install dependencies

Install openzeppelin

OpenZeppelin is a library for secure smart contract development. It provides implementations of standards like ERC20 and ERC721 which you can deploy as-is or extend to suit your needs, as well as Solidity components to build custom contracts and more complex decentralized systems.

npm install --save-dev @openzeppelin/contracts